views:

199

answers:

2

Hi, I am making a slider based component in GWT.

Parent : width = 100%
.-------------------------------------------------.
| .---------------------------------------------. |
| |     Child : width = X                       | |
| '---------------------------------------------' |
'-------------------------------------------------'

where X = (parent's width in px) - (some calculations based on runtime);

My code says:

int providedWidth = parentContainer.getOffsetWidth();

In Firefox, I get the width correctly as (say) 345px But in IE6, it constantly returns the width as 0 no matter what size it is.

From GWT perspective, Parent is an AbsolutePanel placed within a DockPanel (super parent), Child is a a HorizontalPanel.

I haven't placed code here for brevity, is there any other way to get the width or am I doing something wrong ?

+3  A: 

Just a wild guess, but maybe the element needs "layout" in IE6? Can you give it style='zoom:1'?

Pekka
I was about to suggest that. +1
Konrad Rudolph
Does not work,But its a great out-of-the box suggestion: to invoke hasLayout() method.Man I wish this would work,But, IE still reports it as 0.
Salvin Francis
on similar lines, i provided a border to it using ie developer tools and it suddenly popped out !!maybe the hasLayout was not triggered until then...
Salvin Francis
+2  A: 

In IE you sometimes have to get the size information in a DeferredCommand because IE only does the layout after the event thread is done.

David Nouls
Didnt work either, but thanks for the suggestion.
Salvin Francis
What is the type of the parent container ? Is that one really 100% of the browser window ?
David Nouls