java - LayoutPanel getOffsetWidth() returns 0 -
I can not find the actual dimensions of an object when she went the first time and expense by LayoutPanel. I'm using the layout panel for a widget of up to percent: class I onResize () override: My problem is that onResize () until the browser is physically added to the given size , And when I need the correct dimension the object is displayed first. If I forceLayout () is called, it makes a call to onResize (), but getOffsetWidth () returns null. I need to force a call to execute onResize () after that the object is composed of pieces.
MyClass displayObject = new MyClass (); Adding (DisplayObject); SetWidgetLeftWidth (displayObject, 0.0, Unit.PCT, 15.0, UnitPCT); SetWidgetTopHeight (displayObject, 0.0, Unit.PCT, 30.0, Unit PCT);
implement public MyClass extends AbsolutePanel does RequiresResize {@Override public void onResize () {int maxWidth = getOffsetWidth ( ); Integer maxHeight = getOffsetHeight (); // ... here need to use maxWidth ...}}
You browser should give a little time to complete the first layout of asking for a size: .
Scheduler.get () scheduleDeferred (New ScheduledCommand () {@Override public void execute () {int maxWidth = GetOffsetWidth (); int maxHeight = getOffsetHeight (); // etc.}} ); You can read more here:
Comments
Post a Comment