Example #1
0
 @Override
 public void actionPerformed(ActionEvent e) {
   MutableComboBoxModel m = (MutableComboBoxModel) list.getModel();
   if (m.getSize() > 1) {
     m.removeElementAt(index);
     comboBox.showPopup();
   }
 }
Example #2
0
  /** This method is used to change the dynamically label of an object in this JInvidChooser. */
  public void relabelObject(Invid invid, String newLabel) {
    MutableComboBoxModel model = (MutableComboBoxModel) getModel();

    synchronized (model) {
      for (int i = 0; i < model.getSize(); i++) {
        listHandle lh = (listHandle) model.getElementAt(i);

        if (lh != null && lh.getObject() != null && lh.getObject().equals(invid)) {
          model.removeElementAt(i);
          lh.setLabel(newLabel);
          model.insertElementAt(lh, i);
          repaint();
          break;
        }
      }
    }
  }