GWT - Retrieve size of a widget that is not displayed
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
16:13 UTC
Read the original article
Hit count: 170
gwt
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
I could also solve my problem by using the AbsolutePanel size to set the child position and size:
AbsolutePanel aPanel = new AbsolutePanel();
aPanel.setSize("100%", "50px");
HTML text = new HTML(/*variable lenght text*/);
int xPosition = aPanel.getOffsetWidth() / 3; // Once again, getOffsetWidth() returns 0;
aPanel.add(text, xPosition, 0);
In both case, i have to find a way to either:
- retrieve the size of a widget that has not been displayed
- be notified when a widget is displayed
© Stack Overflow or respective owner