Пример #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());
    }
Пример #2
0
  //
  //  Handle checkboxes and menu choices
  //
  public void itemStateChanged(ItemEvent event) {
    Object src = event.getSource();
    if (src == light1OnOffMenu) {
      light1OnOff = light1OnOffMenu.getState();
      light1.setEnable(light1OnOff);
      return;
    }
    if (src == light2OnOffMenu) {
      light2OnOff = light2OnOffMenu.getState();
      light2.setEnable(light2OnOff);
      return;
    }
    if (src == light3OnOffMenu) {
      light3OnOff = light3OnOffMenu.getState();
      light3.setEnable(light3OnOff);
      return;
    }

    // Handle all other checkboxes
    super.itemStateChanged(event);
  }
Пример #3
0
  public void itemStateChanged(ItemEvent event) {
    Object src = event.getSource();

    // Check if it is the coupled background choice
    if (src == coupledBackgroundOnOffMenu) {
      coupledBackgroundOnOff = coupledBackgroundOnOffMenu.getState();
      if (coupledBackgroundOnOff) {
        currentBackgroundColor = currentColor;
        backgroundColorMenu.setCurrent(currentColor);
        Color3f color = (Color3f) colors[currentColor].value;
        background.setColor(color);
        backgroundColorMenu.setEnabled(false);
      } else {
        backgroundColorMenu.setEnabled(true);
      }
    }

    // Handle all other checkboxes
    super.itemStateChanged(event);
  }