2

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

谢谢,安德烈

4

1 回答 1

0

使用 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;
}
于 2010-03-19T08:30:55.650 回答