i want get the uiobject's offsetwidth in gwt. but this value depends:
so, things get complicate, especially when you want get this value of FlowPanel,Label,InlineLabel,etc.. which size is dynamically calculated.
my question: when or how to get offsetwidth properly?
You can get the correct size only after the page is completely rendered. Otherwise you will get zero values. Typically, there are two use cases:
(A) Tell the browser to render your view. Then use Scheduler to make sure the browser has finished rendering, before you check for sizes:
Scheduler.get().scheduleDeferred(new ScheduledCommand() {
@Override
public void execute() {
int width = myPanel.getOffsetWidth();
// do something with this width
]
]
(B) Attach a resize handler to a Window. If a user changes the browser's window size, all width and heights may change. You don't need to use a Scheduler in the ResizeHandler - a browser will complete re-rendering the page before calling the ResizeHandler.