Echo2: How to create a centered Pane?

196 views Asked by At

I'm new to the Echo 2 framework. I think it should be simple, but I found no way to center the generated content horizontally and vertically. Is there any possibility to get a centered ContentPane (or something similar) with a fixed width and height?

thx, André

1

There are 1 answers

0
André On BEST ANSWER

Found the solution with 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;
}