Reputation: 532
I've a TabPanel
which contains a SplitLayoutPanel
with inside two ScrollPanel
, one in the Center and one in the South edge of the dock. When I resize the browser window my SplitLayoutPanel
doesn't resize automatically. I try to solve the problem with this code:
Window.addResizeHandler(new ResizeHandler() {
@Override
public void onResize(ResizeEvent event) {
setSplitPanelSize();
}
});
protected void setSplitPanelSize() {
if (getParent() != null) {
Scheduler.get().scheduleDeferred(new Scheduler.ScheduledCommand() {
@Override
public void execute() {
mainSplitPanel.setSize(getParent().getOffsetWidth() + "px", getParent().getOffsetHeight() + "px");
}
});
}
}
but using getParent()
in order to retrieve TabPanel
size is an unsafe soultion. Is there another way to resize SplitLayoutPanel
(and its elements) on browser resizing?
Upvotes: 2
Views: 4701
Reputation: 43
Zasz is correct.
SplitLayoutPanel mainPanel = new SplitLayoutPanel() {
@Override
public void onResize() {
super.onResize();
//some other resizing stuff
}
};
Upvotes: 4
Reputation: 12528
SplitLayoutPanel implements RequiresResize and ProvidesResize as it extends from DockLayoutPanel. You can override the onResize() method to do what you wish. Also it may be necessary to call the base onResize() method as well in your override.
Upvotes: 3