我试图在GWT中添加/删除面板。首先,我声明了面板和一些标签(用作按钮)。
DockPanel dockPanel = new DockPanel();
RootLayoutPanel rootLayout = RootLayoutPanel.get();
Label one = new Label("First Button");
Label two = new Label("Second Button");
然后我有这个初始化各种面板
public void initPanels() {
dockPanel.add(one, DockPanel.EAST);
rootLayout.add(dockPanel);
我添加了一些点击处理程序,然后将请求发送到此类,然后删除一个面板并将其替换为另一个面板,只有我无法解决如何操作:
public void getActivePanel(String activePanelName){
if (activePanelName==null){
dockPanel.add(one, DockPanel.EAST);
}
else if (activePanelName == "two"){
//can't figure this bit out
//dockPanel.remove(AnotherLabel);
//dockPanel.remove((IsWidget) DockPanel.EAST);
//dockPanel.add(two, DockPanel.EAST);
}
}
答案 0 :(得分:0)
你可以这样做:
dockPanel.remove(one);
dockPanel.add(two, DockPanel.EAST);