I can't get the actual dimensions of an object when it is first created and laid out by the LayoutPanel. I am using LayoutPanel to size a widget by percentage:
MyClass displayObject = new MyClass();
add(displayObject);
setWidgetLeftWidth(displayObject, 0.0, Unit.PCT, 15.0, Unit.PCT);
setWidgetTopHeight(displayObject, 0.0, Unit.PCT, 30.0, Unit.PCT);
In the class I override onResize():
public MyClass extends AbsolutePanel implements RequiresResize {
@Override
public void onResize() {
Integer maxWidth = getOffsetWidth();
Integer maxHeight = getOffsetHeight();
// ... need to use maxWidth here...
}
}
My problem is that onResize() is not called unless the browser is physically resized, and I need the correct dimensions when the object is first displayed.
If I call forceLayout(), it creates a call to onResize(), but getOffsetWidth() returns zero. I need to force a call to onResize() that executes AFTER the object has been laid out.