Пример #1
0
 /**
  * Switches views based on the passed enum.
  *
  * @param v the View to switch to
  * @param o A BattleField if switching to BattleView.
  */
 public void changeView(Views v, Object o) {
   switch (v) {
     case PREVIOUS:
       CardLayout cl = (CardLayout) body.getLayout();
       JPanel temp = currentPanel;
       panels.pop();
       currentPanel = panels.peek();
       cl.show(body, currentPanel.toString());
       cl.removeLayoutComponent(temp);
       break;
     case BATTLE:
       currentPanel = new BattleView(this, (BattleField) o);
       panels.push(currentPanel);
       body.add(currentPanel, v.name());
       CardLayout cl1 = (CardLayout) body.getLayout();
       cl1.show(body, v.name());
       for (Component c : body.getComponents()) {
         if (c == currentPanel) {
           c.requestFocusInWindow();
         }
       }
       break;
     case TITLE:
       currentPanel = new TitleView(this);
       panels.push(currentPanel);
       body.add(currentPanel, v.name());
       CardLayout cl2 = (CardLayout) body.getLayout();
       cl2.show(body, v.name());
       break;
     default:
       // Do nothing
   }
 }
Пример #2
0
 /**
  * Remove the given panel from the card layout and refresh the display.
  *
  * @param panel Panel
  */
 public void legendRemoved(ISELegendPanel panel) {
   cardLayout.removeLayoutComponent(panel.getComponent());
   showDialogForCurrentlySelectedLegend();
 }
Пример #3
0
  public void remove(Component comp) {
    super.remove(comp);
    card.removeLayoutComponent(comp);

    revalidate();
  }