Question

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é

Was it helpful?

Solution

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;
}
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top