我有一个适合整个窗口的ContentPanel。它有一个topComponent,一个位于中心的小部件和一个bottomComponent。GXT(Ext-GWT):ContentPanel的布局问题
我越来越布局的问题,当我尝试小部件添加到的TopComponent后的ContentPanel已经呈现一次:
public void onModuleLoad() {
final Viewport viewport = new Viewport();
viewport.setLayout(new FitLayout());
final ContentPanel contentPanel = new ContentPanel(new FitLayout());
contentPanel.setHeaderVisible(false);
final LayoutContainer topContainer = new LayoutContainer(
new FlowLayout());
final Button buttonOne = new Button("Top:One");
topContainer.add(buttonOne);
contentPanel.setTopComponent(topContainer);
contentPanel.add(new Button("Center"));
contentPanel.setBottomComponent(new Button("Bottom"));
viewport.add(contentPanel);
RootPanel.get().add(viewport);
// Later, add a second button to the topComponent ...
Scheduler.get().scheduleDeferred(new ScheduledCommand() {
@Override
public void execute() {
final Button buttonTwo = new Button("Top:Two");
topContainer.add(buttonTwo); // Doesn't show up at first.
topContainer.layout(); // Now, buttonTwo shows up. But we have
// a new problem: the "Bottom" button disappears...
contentPanel.layout(true); // This doesn't do anything, BTW.
}
});
}
关于这个有趣的是,该布局将自行解决,尽快当我调整浏览器窗口。我可以做些什么来使它重新正确地立即布局(我试过在几个地方和组合中添加几个layout()
等等,但是到目前为止还没有任何运气。)
(我正在使用GWT 2.1.1与2.2.1 GXT)
什么是“越来越布局的问题”是什么意思? – 2011-04-08 15:09:03
@ Travis:像我的代码中的评论一样:首先buttonTwo不显示。然后,当我调用layout()时,它显示出来。但是现在“底部”按钮消失。只要手动调整窗口大小(即使只是一个像素),布局也会自行修正,即所有按钮都显示出来。 – 2011-04-08 17:50:01