GWT SplitLayoutPanel 调整大小
我有一个 TabPanel
,其中包含一个 SplitLayoutPanel
,内部有两个 ScrollPanel
,一个位于码头的中心,一个位于码头的南边缘。当我调整浏览器窗口大小时,我的 SplitLayoutPanel
不会自动调整大小。我尝试用这段代码解决问题:
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");
}
});
}
}
但是使用 getParent()
来检索 TabPanel
大小是不安全的。是否有另一种方法可以在浏览器调整大小时调整 SplitLayoutPanel
(及其元素)的大小?
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?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
扎斯是对的。
Zasz is correct.
SplitLayoutPanel 实现了 RequiresResize 和 ProvidesResize,因为它从 DockLayoutPanel 扩展而来。您可以重写 onResize() 方法来执行您想要的操作。此外,可能还需要在重写中调用基本的 onResize() 方法。
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.