【问题标题】:Echo2: How to create a centered Pane?Echo2:如何创建居中的窗格?
【发布时间】:2010-09-14 06:45:27
【问题描述】:

我是 Echo 2 框架的新手。我认为它应该很简单,但是我发现没有办法将生成的内容水平和垂直居中。 是否有可能获得具有固定宽度和高度的居中 ContentPane(或类似的东西)?

谢谢, 安德烈

【问题讨论】:

    标签: panel center echo2


    【解决方案1】:

    使用 echoPointNG 找到解决方案:

    public static ContainerEx createCenteredPane( int width, int height ) {
        ContainerEx cp = new ContainerEx();
        cp.setPosition( Positionable.ABSOLUTE );
        cp.setOutsets( new Insets( width / 2 * -1, height / 2 * -1, 0, 0 ) );
        cp.setWidth( new Extent( width ) );
        cp.setHeight( new Extent( height ) );
        cp.setLeft( new Extent( 50, Extent.PERCENT ) );
        cp.setTop( new Extent( 50, Extent.PERCENT ) );
        return cp;
    }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2014-06-27
      • 2011-08-06
      • 2013-04-21
      • 2018-01-08
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多