예제 #1
0
 /** 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()
예제 #2
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());
    }
 @Override
 public void itemStateChanged(ItemEvent e) {
   if (e.getItem() == "Free") {
     model.setChoiceFree();
   }
   if (e.getItem() == "Together") {
     model.setChoiceTogether();
   }
   if (e.getItem() == "Against") {
     model.setChoiceAganist();
   }
 }
예제 #4
0
    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();
        }
      }
    }
예제 #5
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);
 }
예제 #6
0
 @Override
 public void itemStateChanged(ItemEvent e) {
   if (e.getItem() == PerfMeasureType.CUSTOM) mAddPerfMeasures.setVisible(true);
   else {
     mAddPerfMeasures.setVisible(false);
     mTypeToWeight.clear();
   }
 }
예제 #7
0
 public void itemStateChanged(ItemEvent event) {
   Object item = event.getItem();
   if (item == gui.quickpick) {
     for (int i = 0; i < 6; i++) {
       int pick;
       do {
         pick = (int) Math.floor(Math.random() * 50 + 1);
       } while (numberGone(pick, gui.numbers, i));
       gui.numbers[i].setText("" + pick);
     }
   } else {
     for (int i = 0; i < 6; i++) {
       gui.numbers[i].setText(null);
     }
   }
 }
예제 #8
0
 // 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);
 }
예제 #9
0
 public void itemRemoved(ItemEvent itemEvent) {
   println("Item removed = " + itemEvent.getItem());
 }
예제 #10
0
 public void itemAdded(ItemEvent itemEvent) {
   println("Item added = " + itemEvent.getItem());
 }
예제 #11
0
    public void itemStateChanged(ItemEvent e) {
      if (e.getStateChange() != ItemEvent.SELECTED) return;

      final Project selectedProject = (Project) e.getItem();
      if (selectedProject.isValid()) issueLoader.setProject(selectedProject);
    }
예제 #12
0
  /**
   * Converts a new event to an old one (used for compatibility). If the new event cannot be
   * converted (because no old equivalent exists) then this returns null.
   *
   * <p>Note: this method is here instead of in each individual new event class in java.awt.event
   * because we don't want to make it public and it needs to be called from java.awt.
   */
  Event convertToOld() {
    Object src = getSource();
    int newid = id;

    switch (id) {
      case KeyEvent.KEY_PRESSED:
      case KeyEvent.KEY_RELEASED:
        KeyEvent ke = (KeyEvent) this;
        if (ke.isActionKey()) {
          newid = (id == KeyEvent.KEY_PRESSED ? Event.KEY_ACTION : Event.KEY_ACTION_RELEASE);
        }
        int keyCode = ke.getKeyCode();
        if (keyCode == KeyEvent.VK_SHIFT
            || keyCode == KeyEvent.VK_CONTROL
            || keyCode == KeyEvent.VK_ALT) {
          return null; // suppress modifier keys in old event model.
        }
        // no mask for button1 existed in old Event - strip it out
        return new Event(
            src,
            ke.getWhen(),
            newid,
            0,
            0,
            Event.getOldEventKey(ke),
            (ke.getModifiers() & ~InputEvent.BUTTON1_MASK));

      case MouseEvent.MOUSE_PRESSED:
      case MouseEvent.MOUSE_RELEASED:
      case MouseEvent.MOUSE_MOVED:
      case MouseEvent.MOUSE_DRAGGED:
      case MouseEvent.MOUSE_ENTERED:
      case MouseEvent.MOUSE_EXITED:
        MouseEvent me = (MouseEvent) this;
        // no mask for button1 existed in old Event - strip it out
        Event olde =
            new Event(
                src,
                me.getWhen(),
                newid,
                me.getX(),
                me.getY(),
                0,
                (me.getModifiers() & ~InputEvent.BUTTON1_MASK));
        olde.clickCount = me.getClickCount();
        return olde;

      case FocusEvent.FOCUS_GAINED:
        return new Event(src, Event.GOT_FOCUS, null);

      case FocusEvent.FOCUS_LOST:
        return new Event(src, Event.LOST_FOCUS, null);

      case WindowEvent.WINDOW_CLOSING:
      case WindowEvent.WINDOW_ICONIFIED:
      case WindowEvent.WINDOW_DEICONIFIED:
        return new Event(src, newid, null);

      case ComponentEvent.COMPONENT_MOVED:
        if (src instanceof Frame || src instanceof Dialog) {
          Point p = ((Component) src).getLocation();
          return new Event(src, 0, Event.WINDOW_MOVED, p.x, p.y, 0, 0);
        }
        break;

      case ActionEvent.ACTION_PERFORMED:
        ActionEvent ae = (ActionEvent) this;
        String cmd;
        if (src instanceof Button) {
          cmd = ((Button) src).getLabel();
        } else if (src instanceof MenuItem) {
          cmd = ((MenuItem) src).getLabel();
        } else {
          cmd = ae.getActionCommand();
        }
        return new Event(src, 0, newid, 0, 0, 0, ae.getModifiers(), cmd);

      case ItemEvent.ITEM_STATE_CHANGED:
        ItemEvent ie = (ItemEvent) this;
        Object arg;
        if (src instanceof List) {
          newid =
              (ie.getStateChange() == ItemEvent.SELECTED ? Event.LIST_SELECT : Event.LIST_DESELECT);
          arg = ie.getItem();
        } else {
          newid = Event.ACTION_EVENT;
          if (src instanceof Choice) {
            arg = ie.getItem();

          } else { // Checkbox
            arg = new Boolean(ie.getStateChange() == ItemEvent.SELECTED);
          }
        }
        return new Event(src, newid, arg);

      case AdjustmentEvent.ADJUSTMENT_VALUE_CHANGED:
        AdjustmentEvent aje = (AdjustmentEvent) this;
        switch (aje.getAdjustmentType()) {
          case AdjustmentEvent.UNIT_INCREMENT:
            newid = Event.SCROLL_LINE_DOWN;
            break;
          case AdjustmentEvent.UNIT_DECREMENT:
            newid = Event.SCROLL_LINE_UP;
            break;
          case AdjustmentEvent.BLOCK_INCREMENT:
            newid = Event.SCROLL_PAGE_DOWN;
            break;
          case AdjustmentEvent.BLOCK_DECREMENT:
            newid = Event.SCROLL_PAGE_UP;
            break;
          case AdjustmentEvent.TRACK:
            if (aje.getValueIsAdjusting()) {
              newid = Event.SCROLL_ABSOLUTE;
            } else {
              newid = Event.SCROLL_END;
            }
            break;
          default:
            return null;
        }
        return new Event(src, newid, new Integer(aje.getValue()));

      default:
    }
    return null;
  }
예제 #13
0
 public void itemStateChanged(ItemEvent e) {
   PlayerType ptype = (PlayerType) e.getItem();
   CardLayout cl = (CardLayout) mTabs.getLayout();
   assert (cl.getClass() == CardLayout.class);
   cl.show(mTabs, ptype.toString());
 }
 public void itemStateChanged(ItemEvent i) {
   if (i.getStateChange() == ItemEvent.SELECTED) co = (String) i.getItem();
   z = 1;
 }
예제 #15
0
 public void itemStateChanged(ItemEvent e) {
   texta.setText(
       lblName.getText() + text0.getText() + '\n' + lblAcad.getText() + e.getItem());
 }