Пример #1
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);
  }
Пример #2
0
  //
  //  Handle checkboxes and menu choices
  //
  public void checkboxChanged(CheckboxMenu menu, int check) {
    if (menu == backgroundColorMenu) {
      // Change the background color
      currentBackgroundColor = check;
      Color3f color = (Color3f) colors[check].value;
      background.setColor(color);
      return;
    }
    if (menu == colorMenu) {
      // Change the fog color
      currentColor = check;
      Color3f color = (Color3f) colors[check].value;
      fog.setColor(color);

      // If background is coupled, set the background color
      if (coupledBackgroundOnOff) {
        currentBackgroundColor = currentColor;
        backgroundColorMenu.setCurrent(check);
        background.setColor(color);
      }
      return;
    }
    if (menu == frontMenu) {
      // Change the fog front distance
      currentFront = check;
      float front = ((Float) fronts[currentFront].value).floatValue();
      fog.setFrontDistance(front);
      return;
    }
    if (menu == backMenu) {
      // Change the fog back distance
      currentBack = check;
      float back = ((Float) backs[currentBack].value).floatValue();
      fog.setBackDistance(back);
      return;
    }

    // Handle all other checkboxes
    super.checkboxChanged(menu, check);
  }