Я не использовал конкретные виджеты, которые вы используете, но это общая идея.
public class Index implements EntryPoint {
public void onModuleLoad() {
// the panel that holds the content widgets
final SimplePanel mainPanel = new SimplePanel();
// the panel that holds the links
FlowPanel leftPanel = new FlowPanel();
// the first content widget
final Label oneContent = new Label("one content");
// the second content widget
final Label twoContent = new Label("two content");
// the anchor to load the first content widget when clicked
Anchor one = new Anchor("one menu");
// add the click handler to do the content swap
one.addClickHandler(new ClickHandler() {
@Override
public void onClick(ClickEvent event) {
// remove any previous content
mainPanel.clear();
// add the first content widget
mainPanel.add(oneContent);
}
});
// the anchor to load the first content widget when clicked
Anchor two = new Anchor("two menu");
// add the click handler to do the content swap
two.addClickHandler(new ClickHandler() {
@Override
public void onClick(ClickEvent event) {
// remove any previous content
mainPanel.clear();
// add the second content widget
mainPanel.add(twoContent);
}
});
leftPanel.add(one);
leftPanel.add(two);
// add everything to the RootPanel
RootPanel.get().add(leftPanel);
RootPanel.get().add(mainPanel);
}
}
Вы посмотрели источник на образец Почты? http://code.google.com/p/google-web-toolkit/source/browse/#svn/trunk/samples/mail/src/com/google/gwt/sample/mail - это довольно старый код, но основы того, что происходит, должны быть там. –
Джейсон, у меня есть ... но он не может ответить на вопрос, что касается элементов StackLayoutPanel динамически виджета в одной из областей макета панели Dock Panel ... все дым и зеркала в этом отношении – murray
действительно то, что вы просите, как поменять один виджет на другой на основе события click, не так ли? –