public void itemStateChanged(ItemEvent evt) {
    // Update all objects that share this item
    boolean newValue;
    boolean oldValue = this.selected;

    if (evt.getStateChange() == ItemEvent.SELECTED) {
      newValue = true;
    } else {
      newValue = false;
    }

    if (oldValue != newValue) {
      setSelected(newValue);

      // Forward the event to the delgate for handling.
      if (listener != null) {
        listener.itemStateChanged(evt);
      }
    }
  }
  /** Creates the layout of the panel (but the contents are not populated here). */
  private void createLayout() {
    GridBagConstraints gbc = new GridBagConstraints();
    gbc.anchor = GridBagConstraints.WEST;
    gbc.weightx = 0.0;
    gbc.gridx = 0;
    gbc.gridy = 0;
    gbc.gridwidth = 3;
    addErrorPane(gbc);
    gbc.gridwidth = 1;
    gbc.fill = GridBagConstraints.NONE;
    lBaseDN = Utilities.createPrimaryLabel(INFO_CTRL_PANEL_BASE_DN_LABEL.get());
    add(lBaseDN, gbc);
    gbc.insets.left = 10;
    gbc.gridx = 1;
    gbc.gridy = 0;
    baseDNs = Utilities.createComboBox();
    DefaultComboBoxModel model = new DefaultComboBoxModel();
    baseDNs.setModel(model);
    baseDNs.setRenderer(new CustomListCellRenderer(baseDNs));
    ItemListener listener = new IgnoreItemListener(baseDNs);
    baseDNs.addItemListener(listener);
    baseDNs.addItemListener(
        new ItemListener() {
          /** {@inheritDoc} */
          public void itemStateChanged(ItemEvent ev) {
            comboBoxSelected(
                hmIndexes, (CategorizedComboBoxElement) baseDNs.getSelectedItem(), addRemove);
          }
        });
    listener.itemStateChanged(null);
    add(baseDNs, gbc);
    lNoBaseDNsFound = Utilities.createDefaultLabel(INFO_CTRL_PANEL_NO_BASE_DNS_FOUND_LABEL.get());
    add(lNoBaseDNsFound, gbc);
    lNoBaseDNsFound.setVisible(false);

    lIndexes = Utilities.createPrimaryLabel(INFO_CTRL_PANEL_INDEXES_LABEL.get());
    gbc.insets.top = 10;
    gbc.insets.left = 0;
    gbc.gridy++;
    gbc.gridx = 0;
    gbc.gridwidth = 1;
    gbc.anchor = GridBagConstraints.NORTHWEST;
    add(lIndexes, gbc);

    addRemove = new AddRemovePanel<AbstractIndexDescriptor>(AbstractIndexDescriptor.class);
    addRemove.getAvailableLabel().setText(INFO_CTRL_PANEL_AVAILABLE_INDEXES_LABEL.get().toString());
    addRemove.getSelectedLabel().setText(INFO_CTRL_PANEL_SELECTED_INDEXES_LABEL.get().toString());

    gbc.gridx = 1;
    gbc.weightx = 1.0;
    gbc.weighty = 0.0;
    gbc.gridwidth = 1;
    gbc.insets.top = 10;
    gbc.insets.left = 10;
    gbc.fill = GridBagConstraints.BOTH;
    add(addRemove, gbc);

    gbc.gridy++;
    gbc.insets.top = 3;
    JLabel explanation =
        Utilities.createInlineHelpLabel(INFO_CTRL_PANEL_REQUIRES_REBUILD_LEGEND.get());
    add(explanation, gbc);

    addBottomGlue(gbc);
  }
 private void notifyItemListeners() {
   for (ItemListener listener : listenerList.getListeners(ItemListener.class)) {
     int type = selectedAct == null ? ItemEvent.DESELECTED : ItemEvent.SELECTED;
     listener.itemStateChanged(new ItemEvent(this, 0, selectedAct, type));
   }
 }
 /**
  * Handles the itemStateChanged event by invoking the itemStateChanged methods on listener-a and
  * listener-b.
  *
  * @param e the item event
  */
 public void itemStateChanged(ItemEvent e) {
   ((ItemListener) a).itemStateChanged(e);
   ((ItemListener) b).itemStateChanged(e);
 }
Esempio n. 5
0
 /**
  * This method processes the specified event by dispatching it to any registered listeners. Note
  * that this method will only get called if item events are enabled. This will happen
  * automatically if any listeners are added, or it can be done "manually" by calling the <code>
  * enableEvents()</code> method.
  *
  * @param event The event to process.
  */
 protected void processItemEvent(ItemEvent event) {
   if (item_listeners != null) item_listeners.itemStateChanged(event);
 }