Пример #1
0
    public void itemStateChanged(ItemEvent event) {
      CheckboxMenuItem theMenuItem = (CheckboxMenuItem) (event.getSource());

      String strIndex =
          theMenuItem
              .getActionCommand()
              .substring(theMenuItem.getActionCommand().lastIndexOf('.') + 1);
      int index = (new Integer(strIndex)).intValue();
      if (theMenuItem.getState()) {
        ((Component) visibleMapLayers.elementAt(index)).setVisible(true);
      } else {
        ((Component) visibleMapLayers.elementAt(index)).setVisible(false);
      }

      System.out.println("Action = " + theMenuItem.getActionCommand());
      System.out.println("       = " + theMenuItem.getState());
    }