GWT - Retrieve size of a widget inside an AbsolutePanel

Posted by Garagos on Stack Overflow See other posts from Stack Overflow or by Garagos
Published on 2010-04-22T15:20:24Z Indexed on 2010/04/22 15:23 UTC
Read the original article Hit count: 172

Filed under:

I need to set the size of an absolutePanel regarding to its child size, but the getOffset* methods return 0 because (i think) the child as not been displayed yet.

A Quick example:

AbsolutePanel aPanel = new AbsolutePanel();
HTML text = new HTML(/*variable lenght text*/);
int xPosition = 20; // actually variable
aPanel.add(text, xPosition, 0);
aPanel.setSize(xPosition + text .getOffsetWidth() + "px", "50px"); // 20px 50px

Is there a way to:

  • retrieve the size of a widget that has not been displayed?
  • be notified when a widget is displayed ?

© Stack Overflow or respective owner

Related posts about gwt