GXT (Ext-GWT): проблемы макета с ContentPanel

У меня есть ContentPanel, которая умещается во все окно. У него есть topComponent, виджет в центре и bottomComponent.

У меня проблемы с макетом, когда я пытаюсь добавить виджеты в 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 с GXT 2.2.1.)

6
задан Chris Lercher 11 April 2011 в 12:01
поделиться