我有一個適合整個窗口的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