Pregunta

Soy nuevo en el framework Echo 2. Creo que debería ser simple, pero no encontré una manera de centrar el contenido generado horizontal y verticalmente. ¿Existe alguna posibilidad de obtener un ContentPane centrado (o algo similar) con un ancho y una altura fijos?

gracias André

¿Fue útil?

Solución

Encontré la solución con 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;
}
Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top