This code got error
@Override
public void onClick(ClickEvent event) {
// TODO Auto-generated method stub
mainDockPanel.remove(panel1);
mainDockPanel.remove(panel2);
if(mainDockPanel.getWidgetDirection(panel1).equals(DockPanel.EAST)){
mainDockPanel.add(panel1, DockPanel.WEST);
mainDockPanel.add(panel2, DockPanel.EAST);
}
else if (mainDockPanel.getWidgetDirection(panel1).equals(DockPanel.WEST)){
mainDockPanel.add(panel1, DockPanel.EAST);
mainDockPanel.add(panel2, DockPanel.WEST);
}
}
Somethign wrong with this code?
Also, is there any other better solution to swap 2 panel?
First you removed panel1 from mainDockPanel.
Then you use if(mainDockPanel.getWidgetDirection(panel1).equals(DockPanel.EAST)){
From the API docs
the widget's layout direction, or null if it is not a child of this panel Blockquote
Chances are, you are getting a NPE