Example #1
0
 /** Handles CheckboxMenuItem state changes. */
 public void itemStateChanged(ItemEvent e) {
   MenuItem item = (MenuItem) e.getSource();
   MenuComponent parent = (MenuComponent) item.getParent();
   String cmd = e.getItem().toString();
   if ((Menu) parent == Menus.window) WindowManager.activateWindow(cmd, item);
   else doCommand(cmd);
 }
Example #2
0
  public void itemStateChanged(ItemEvent evt) {
    if (evt.getSource() == farbe) {
      status.setText("Farbe " + farben[farbe.getSelectedIndex()] + " ausgewaehlt");

      switch (farbe.getSelectedIndex()) {
        case 0:
          color = Color.blue;
          break;
        case 1:
          color = Color.yellow;
          break;
        case 2:
          color = Color.green;
          break;
        case 3:
          color = Color.red;
          break;
        case 4:
          color = Color.black;
          break;
        case 5:
          color = Color.white;
      }
    } else if (evt.getSource() == filled) {
      if (filled.getState() == true) status.setText("Ausgefuellt zeichnen");
      else status.setText("Rahmen zeichnen");
    }
  }
  public void itemStateChanged(ItemEvent E) {
    // The 'log chat' checkbox
    if (E.getSource() == logChat) {
      server.logChats = logChat.getState();

      // Loop through all of the chat rooms, and set the logging
      // state to be the same as the value of the checkbox
      for (int count = 0; count < server.chatRooms.size(); count++) {
        babylonChatRoom tmp = (babylonChatRoom) server.chatRooms.elementAt(count);
        try {
          tmp.setLogging(server.logChats);
        } catch (IOException e) {
          server.serverOutput(
              server.strings.get(thisClass, "togglelogerror") + " " + tmp.name + "\n");
        }
      }
    }

    // The user list
    if (E.getSource() == userList) {
      // If anything is selected, enable the 'disconnect user'
      // button, otherwise disable it
      synchronized (userList) {
        disconnect.setEnabled(userList.getSelectedItem() != null);
      }
    }
  }
    public void itemStateChanged(ItemEvent e) {
      if (e.getStateChange() == ItemEvent.SELECTED) {
        int oldDay = selectedDay;
        int oldMonth = selectedMonth;
        int oldYear = selectedYear;

        String dayString = ((JToggleButton) e.getItem()).getText();
        try {
          selectedDay = Integer.parseInt(dayString);
        } catch (Exception ex) {
          selectedDay = 1;
        }
        selectedMonth = displayMonth;
        selectedYear = displayYear;

        if (oldDay != selectedDay || oldMonth != selectedMonth || oldYear != selectedYear) {

          isNullDate = false;
          selectedCalendar.set(Calendar.YEAR, selectedYear);
          selectedCalendar.set(Calendar.MONTH, selectedMonth);
          selectedCalendar.set(Calendar.DATE, selectedDay);

          updateCalendarComponents();
          fireDateChange();
        }
      }
    }
Example #5
0
 /** For the user selected answer event. */
 public void itemStateChanged(ItemEvent evt) { // ***Event
   if (evt.getStateChange() == ItemEvent.SELECTED) {
     if (evt.getSource() == cBox_Price) {
       que.setUserChoice(Q4_PriceDistance.PRICE);
     } else if (evt.getSource() == cBox_Distance) {
       que.setUserChoice(Q4_PriceDistance.DISTANCE);
     }
   }
 }
 @Override
 public void itemStateChanged(ItemEvent e) {
   Object source = e.getItemSelectable();
   CPArtwork artwork = controller.getArtwork();
   if (source == cbSampleAllLayers) {
     artwork.setSampleAllLayers(e.getStateChange() == ItemEvent.SELECTED);
   } else if (source == cbLockAlpha) {
     artwork.setLockAlpha(e.getStateChange() == ItemEvent.SELECTED);
   }
 }
Example #7
0
    /**
     * Invoked when an item has been selected or deselected by the user. The code written for this
     * method performs the operations that need to occur when an item is selected (or deselected).
     */
    @Override
    public void itemStateChanged(ItemEvent e) {
      String result = null;
      if (e.getSource().equals(cm_debug)) {
        result = (String) e.getItem();
      } else if (e.getSource().equals(cm_test)) {
        result = (String) e.getItem();
      }

      updateDebugPanelState(result, cm_debug.getState(), cm_test.getState());
    }
Example #8
0
  public void itemStateChanged(ItemEvent e) {
    System.out.println("itemStateChanged");
    if (e.getSource() == ColChoice) // 预选颜色
    {
      String name = ColChoice.getSelectedItem();

      if (name == "black") {
        c = new Color(0, 0, 0);
      } else if (name == "red") {
        c = new Color(255, 0, 0);
      } else if (name == "green") {
        c = new Color(0, 255, 0);
      } else if (name == "blue") {
        c = new Color(0, 0, 255);
      }
    } else if (e.getSource() == SizeChoice) // 画笔大小
    {
      String selected = SizeChoice.getSelectedItem();

      if (selected == "1") {
        con = 1;
        size = new BasicStroke(con, BasicStroke.CAP_BUTT, BasicStroke.JOIN_BEVEL);

      } else if (selected == "3") {
        con = 3;
        size = new BasicStroke(con, BasicStroke.CAP_BUTT, BasicStroke.JOIN_BEVEL);

      } else if (selected == "5") {
        con = 5;
        size = new BasicStroke(con, BasicStroke.CAP_BUTT, BasicStroke.JOIN_BEVEL);

      } else if (selected == "7") {
        con = 7;
        size = new BasicStroke(con, BasicStroke.CAP_BUTT, BasicStroke.JOIN_BEVEL);

      } else if (selected == "9") {
        con = 9;
        size = new BasicStroke(con, BasicStroke.CAP_BUTT, BasicStroke.JOIN_BEVEL);
      }
    } else if (e.getSource() == EraserChoice) // 橡皮大小
    {
      String Esize = EraserChoice.getSelectedItem();

      if (Esize == "5") {
        Econ = 5 * 2;
      } else if (Esize == "9") {
        Econ = 9 * 2;
      } else if (Esize == "13") {
        Econ = 13 * 2;
      } else if (Esize == "17") {
        Econ = 17 * 3;
      }
    }
  }
Example #9
0
 public void itemStateChanged(ItemEvent evt) {
   if (evt.getSource().equals(box_black)) {
     box_color = Color.black;
   } else if (evt.getSource().equals(box_red)) {
     box_color = Color.red;
   } else if (evt.getSource().equals(box_gray)) {
     box_color = Color.gray;
   } else if (evt.getSource().equals(box_blue)) {
     box_color = Color.blue;
   }
 }
  public void itemStateChanged(ItemEvent e) {
    if (e.getStateChange() == ItemEvent.SELECTED) {
      p5.add(mortgage);
      Slot pobject;
      pobject = Game.SlotsList[x.getProperties().get(propertydisplay.getSelectedIndex())];
      if (pobject instanceof Property) {
        ((Property) (pobject)).monopolizeProperty();
        pr1.setText("Buy Price:" + pobject.getBuyPrice());
        pr2.setText("Rent Price:" + pobject.getRentPrice());
        pr3.setText("House Price:" + pobject.getHousePrice());
        pr4.setText("Hotel Price:" + pobject.getHotelPrice());
        pr5.setText("Mortgaged:" + pobject.getMortgage());
      } else if (pobject instanceof Railroad) {
        pobject.adjustRentPrice();
        pr1.setText("Buy Price:" + pobject.getBuyPrice());
        pr2.setText("Rent Price:" + pobject.getRentPrice());
        pr3.setText("");
        pr4.setText("");
        pr5.setText("");

      } else {
        pobject.adjustDiceFactor();
        pr1.setText("Buy Price:" + pobject.getBuyPrice());
        pr2.setText("Dice Factor:" + pobject.getDiceFactor());
        pr3.setText("");
        pr4.setText("");
        pr5.setText("");
      }
    }
  }
Example #11
0
 @Override
 public void itemStateChanged(ItemEvent e) {
   // TODO Auto-generated method stub
   if (e.getSource() == box) {
     getFindData();
   }
 }
Example #12
0
 public void itemStateChanged(ItemEvent e) {
   JMenuItem source = (JMenuItem) (e.getSource());
   String s =
       "Item event detected."
           + newline
           + "    Event source: "
           + source.getText()
           + " (an instance of "
           + getClassName(source)
           + ")"
           + newline
           + "    New state: "
           + ((e.getStateChange() == ItemEvent.SELECTED) ? "selected" : "unselected");
   output.append(s + newline);
   output.setCaretPosition(output.getDocument().getLength());
 }
Example #13
0
 @Override
 public void itemStateChanged(ItemEvent e) {
   if (e.getItem() == PerfMeasureType.CUSTOM) mAddPerfMeasures.setVisible(true);
   else {
     mAddPerfMeasures.setVisible(false);
     mTypeToWeight.clear();
   }
 }
Example #14
0
  public void itemStateChanged(ItemEvent ie) {

    if (ie.getSource() == c1) {
      String s = c1.getLabel();
      g = s;
    } else {
      String s = c2.getLabel();
      g = s;
    }
  }
Example #15
0
  /** Handle ItemEvents. */
  public void itemStateChanged(ItemEvent e) {

    final String dialog_title = ResourceHandler.getMessage("template_dialog.title");

    Component target = (Component) e.getSource();

    if (target == recursiveCheckBox) {
      converter.setRecurse(recursiveCheckBox.isSelected());
    } else if (target == staticVersioningRadioButton || target == dynamicVersioningRadioButton) {
      converter.setStaticVersioning(staticVersioningRadioButton.isSelected());
    } else if (target == templateCh
        && (e.getStateChange() == e.SELECTED)) { // Process only when item is Selected

      // Get the current template selection
      String choiceStr = (String) templateCh.getSelectedItem();

      // If the user chooses 'other', display a file dialog to allow
      // them to select a template file.
      if (choiceStr.equals(TemplateFileChoice.OTHER_STR)) {
        String templatePath = null;
        FileDialog fd = new FileDialog(this, dialog_title, FileDialog.LOAD);
        fd.show();

        // Capture the path entered, if any.
        if (fd.getDirectory() != null && fd.getFile() != null) {
          templatePath = fd.getDirectory() + fd.getFile();
        }

        // If the template file is valid add it and select it.
        if (templatePath != null && setTemplateFile(templatePath)) {
          if (!templateCh.testIfInList(templatePath)) {
            templateCh.addItem(templatePath);
          }
          templateCh.select(templatePath);
        } else {
          templateCh.select(templateCh.getPreviousSelection());
        }
        fd.dispose();
      } else {
        templateCh.select(choiceStr);
      }
    }
  }
Example #16
0
 public void itemStateChanged(ItemEvent e) {
   if (e.getStateChange() == ItemEvent.SELECTED) {
     scale = parseScale(cmbScale.getSelectedItem().toString());
     if (scale < 100) {
       scale = 100;
     } else if (scale > 100000) {
       scale = 100000;
     }
     cmbScale.setSelectedItem("1:" + scale);
     guiChanged();
   }
 }
 /** Capture des évènements des menus choix */
 public void itemStateChanged(ItemEvent e) {
   if (e.getSource().equals(choix_couleur0)) {
     if (e.getItem() == "rouge") {
       choix_couleur0.setBackground(Color.red);
       choix_couleur1.setBackground(Color.blue);
       choix_couleur1.select("bleu");
       couleurs[0] = ROUGE;
       couleurs[1] = BLEU;
     }
     if (e.getItem() == "bleu") {
       choix_couleur0.setBackground(Color.blue);
       choix_couleur1.setBackground(Color.red);
       choix_couleur1.select("rouge");
       couleurs[0] = BLEU;
       couleurs[1] = ROUGE;
     }
   }
   if (e.getSource().equals(choix_couleur1)) {
     if (e.getItem() == "rouge") {
       choix_couleur1.setBackground(Color.red);
       choix_couleur0.setBackground(Color.blue);
       choix_couleur0.select("bleu");
       couleurs[1] = ROUGE;
       couleurs[0] = BLEU;
     }
     if (e.getItem() == "bleu") {
       choix_couleur1.setBackground(Color.blue);
       choix_couleur0.setBackground(Color.red);
       choix_couleur0.select("rouge");
       couleurs[1] = BLEU;
       couleurs[0] = ROUGE;
     }
   }
 } // itemStateChanged()
Example #18
0
    // GL
    public synchronized void itemStateChanged(ItemEvent e) {
      if (e.getSource() == hsb) isRGB = false;
      if (e.getSource() == rgb) isRGB = true;

      if (e.getSource() == hsb || e.getSource() == rgb) {
        flag = true;
        originalB.setEnabled(false);
        filteredB.setEnabled(false);

        minHue = minSat = minBri = 0;
        maxHue = maxSat = maxBri = 255;

        bandPassH.setState(true);
        bandPassS.setState(true);
        bandPassB.setState(true);
      }
      reset(imp, ip);
      ip = setup(imp);
      apply(imp, ip);
      updateNames();
      notify();
    }
Example #19
0
    public void itemStateChanged(ItemEvent e) {
      Checkbox ch = (Checkbox) e.getSource();
      String label = ch.getLabel();

      if (checkbox.getState() == true) {
        for (int i = 0; i < 3; i++) {
          cb[i].setEnabled(true);
        }
      } else if (checkbox.getState() == false) {
        for (int i = 0; i < 3; i++) {
          cb[i].setEnabled(false);
        }
      }

      if (e.getStateChange() == ItemEvent.SELECTED) {
        System.out.println(label + " selected.");
        lb.setText(label + " selected.");
      } else {
        System.out.println(label + " deselected.");
        lb.setText(label + " deselected.");
      }
    }
Example #20
0
  private void cmbLieferantItemStateChanged(ItemEvent e) {
    if (e.getStateChange() == ItemEvent.SELECTED && cmbLieferant.getSelectedIndex() > 0) {

      lieferant = (Lieferanten) cmbLieferant.getSelectedItem();
      Tools.log(txtLog, "=================================================================");
      Tools.log(txtLog, "Ab jetzt wird auf Lieferant: \"" + lieferant.getFirma() + "\" umgebucht.");
      Tools.log(txtLog, "=================================================================");
      loadVorratTable();
      txtSearch.requestFocus();
    } else {
      lieferant = null;
    }
  }
Example #21
0
  //  Handle checkbox changed events
  public void itemStateChanged(ItemEvent event) {
    Object src = event.getSource();

    for (int i = 0; i < checks.length; i++) {
      if (src == checks[i]) {
        // Update the checkboxes
        checks[current].setState(false);
        current = i;
        checks[current].setState(true);

        if (listener != null) listener.checkboxChanged(this, i);
        return;
      }
    }
  }
Example #22
0
 @Override
 public void itemStateChanged(ItemEvent ev) {
   if (ev.getStateChange() == ItemEvent.SELECTED) {
     SwingUtilities.invokeLater(
         new Runnable() {
           @Override
           public void run() {
             String newPainterName =
                 ((myjava.gui.syntax.Painter) (painterComboBox.getSelectedItem())).getName();
             cardLayout.show(centerPanel, newPainterName);
             centerPanel.revalidate();
             centerPanel.repaint();
           }
         });
   }
 }
Example #23
0
    @Override
    public void itemStateChanged(ItemEvent e) {
      // TODO Auto-generated method stub
      Object source = e.getSource();
      Font tmp = example.getFont();
      int style = tmp.getStyle();

      if (source == italic)
        if (italic.isSelected()) style = style | Font.ITALIC; // turn italic on
        else style = style & ~Font.ITALIC; // turn italic off
      else if (source == bold)
        if (bold.isSelected()) style = style | Font.BOLD; // turn bold on
        else style = style & ~Font.BOLD; // turn bold off

      example.setFont(new Font(tmp.getFamily(), style, tmp.getSize()));
    }
Example #24
0
  private void cmbLagerItemStateChanged(ItemEvent e) {
    if (e.getStateChange() == ItemEvent.SELECTED) {

      vorratsListeInsLogbuch();

      ziel = (Lager) cmbLager.getSelectedItem();
      Tools.log(txtLog, "=================================================================");
      Tools.log(txtLog, "Ab jetzt wird ins Lager: \"" + ziel.getBezeichnung() + "\" umgebucht.");
      Tools.log(txtLog, "=================================================================");
      Main.getProps()
          .put(
              "touch" + MODULENUMBER + "lager",
              new Integer(cmbLager.getSelectedIndex()).toString());
      loadVorratTable();
      txtSearch.requestFocus();
    }
  }
    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());
    }
 // Item Listener stuff
 public void showMessages(ItemEvent e) {
   int index = 0;
   if (e != null) index = ((Integer) e.getItem()).intValue();
   allmessagesTextArea.setText("");
   TracesSession tS = tracesSessions.elementAt(index);
   for (int i = 0; i < tS.size(); i++) {
     TracesMessage tM = tS.elementAt(i);
     // allmessagesTextArea.setForeground(Color.red);
     // allmessagesTextArea.setFont(new Font ("Dialog", 1, 18));
     allmessagesTextArea.append(
         "Message " + (i + 1) + " from " + tM.getFrom() + " to " + tM.getTo());
     allmessagesTextArea.append("\n\n");
     // allmessagesTextArea.setForeground(Color.black);
     // allmessagesTextArea.setFont(new Font ("Dialog", 1, 14));
     allmessagesTextArea.append(tM.getMessageString());
     allmessagesTextArea.append("\n");
   }
   allmessagesTextArea.select(0, 0);
 }
Example #27
0
    public void itemStateChanged(ItemEvent ie) {
      if (ie.getSource() == red) {
        if (ie.getStateChange() == ItemEvent.SELECTED) redValue = 255;
        else redValue = 0;
      } else if (ie.getSource() == green) {
        if (ie.getStateChange() == ItemEvent.SELECTED) greenValue = 255;
        else greenValue = 0;
      } else if (ie.getSource() == blue) {
        if (ie.getStateChange() == ItemEvent.SELECTED) blueValue = 255;
        else blueValue = 0;
      }

      label.setBackground(new Color(redValue, greenValue, blueValue));
    }
Example #28
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);
  }
 public void itemStateChanged(ItemEvent e) {
   Object obj = e.getSource();
   if (obj == choice) {
     graph.newStat = true;
     if (choice.getSelectedItem().equals("Show Sequences")) {
       if (graph.originX * graph.originX + graph.originY * graph.originY < 9) {
         graph.originX = 40.0;
         graph.originY = 2 * Math.PI;
         graph.setZoom(15);
       }
     } else {
       if (graph.originX * graph.originX + graph.originY * graph.originY > 9) {
         graph.originX = 0.0;
         graph.originY = 0.0;
         graph.setZoom(11);
       }
     }
     graph.repaint();
   }
 }
Example #30
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);
  }