I'm unable to get the height of the widget in my code
docklayoutpanel.setHeight("1900px");
String height=Integer.toString(docklayoutpanel.getOffsetHeight());
String heightt=height+"px";
System.out.println(heightt);
but the o/p is always 0px.
I'm unable to get the height of the widget in my code
docklayoutpanel.setHeight("1900px");
String height=Integer.toString(docklayoutpanel.getOffsetHeight());
String heightt=height+"px";
System.out.println(heightt);
but the o/p is always 0px.
The question is old but I had the same problem and it took me quite long to solve it. So to help others here is my solution. I'm using UIBinder to constuct my views and in the constructor I added a Scheduler.
public class MyWidgetImpl extends Composite implements MyWidget {
@UiTemplate("MyWidget.ui.xml")
interface MainViewUiBinder extends UiBinder<Widget, MyWidgetImpl> {
}
@UiField(provided = true)
InputPanel inputPanel;
@UiField(provided = true)
ResultPanel resultPanel;
public MyWidgetImpl() {
inputPanel = ClientFactory.getInputPanel();
resultPanel = ClientFactory.getResultPanel();
MainViewUiBinder uiBinder = GWT.create(MainViewUiBinder.class);
initWidget(uiBinder.createAndBindUi(this));
Window.addResizeHandler(new ResizeHandler() {
public void onResize(ResizeEvent event) {
resize();
}
});
Scheduler.get().scheduleDeferred(new Scheduler.ScheduledCommand() {
public void execute() {
resize();
}
});
}
private void resize() {
if(Window.getClientHeight() > resultPanel.getCellTree().getAbsoluteTop())
resultPanel.getScrollPanel().setHeight((Window.getClientHeight() - resultPanel.getCellTree().getAbsoluteTop()) + "px");
}
}