Java Code Examples for javax.swing.JComboBox#removeAllItems()

The following examples show how to use javax.swing.JComboBox#removeAllItems() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: EditTeamService.java    From Shuffle-Move with GNU General Public License v3.0 6 votes vote down vote up
private void updateKeybindComboBoxes() {
   Team curTeam = getCurrentTeam();
   for (String name : curTeam.getNames()) {
      ItemListener itemListener = nameToItemListenerMap.get(name);
      JComboBox<Character> box = nameToKeybindComboboxMap.get(name);
      box.removeItemListener(itemListener);
      Character prevSelected = box.getItemAt(box.getSelectedIndex());
      box.removeAllItems();
      Character curBinding = curTeam.getBinding(name);
      LinkedHashSet<Character> availableBindings = new LinkedHashSet<Character>(Arrays.asList(curBinding));
      availableBindings.addAll(myData.getAllAvailableBindingsFor(name, curTeam));
      for (Character ch : availableBindings) {
         if (ch != null) {
            box.addItem(ch);
         }
      }
      box.setSelectedItem(prevSelected);
      if (box.getSelectedIndex() < 0) {
         LOG.warning(getString(KEY_NO_BINDINGS));
      }
      box.addItemListener(itemListener);
   }
}
 
Example 2
Source File: OptionPanel.java    From jplag with GNU General Public License v3.0 6 votes vote down vote up
private void updateBasecodeCombo() {
	int selindex = 0, numadded = 1;
	JComboBox<String> cb = getJBasecodeCB();
	cb.removeAllItems();
	cb.addItem(Messages.getString("OptionPanel.none")); //$NON-NLS-1$
	
	if(previewSubs == null) return;
	for(int i = 0; i < previewSubs.size(); i++) {
		SubmissionManager sub = previewSubs.get(i);
		if(sub.isValid() && sub.isDirectory()) {
			cb.addItem(sub.name);
			if(sub.name.equals(oldBasecodeDir)) selindex = numadded;
			numadded++;
		}
	}
	cb.setSelectedIndex(selindex);
}
 
Example 3
Source File: AddressField.java    From LoboBrowser with MIT License 6 votes vote down vote up
private void populateCombo(final String comboBoxText) {
  // Expected to be called in GUI thread.
  this.populatingMatches = true;
  try {
    final JComboBox<String> urlComboBox = this;
    urlComboBox.removeAllItems();
    final Collection<String> recentUrls = ComponentSource.getRecentLocations(30);
    for (final String url : recentUrls) {
      urlComboBox.addItem(url);
    }
    this.setText(comboBoxText);
    this.comboHasHeadMatches = false;
    this.comboInvalid = false;
  } finally {
    this.populatingMatches = false;
  }
}
 
Example 4
Source File: SortPaneProvider.java    From lucene-solr with Apache License 2.0 6 votes vote down vote up
private void resetField(JComboBox<String> fieldCombo, JComboBox<String> typeCombo, JComboBox<String> orderCombo) {
  typeCombo.removeAllItems();
  if (StringUtils.isNullOrEmpty((String) fieldCombo.getSelectedItem())) {
    typeCombo.addItem("");
    typeCombo.setEnabled(false);
    orderCombo.setEnabled(false);
  } else {
    List<SortField> sortFields = searchModel.guessSortTypes((String) fieldCombo.getSelectedItem());
    sortFields.stream()
        .map(sf -> {
          if (sf instanceof SortedNumericSortField) {
            return ((SortedNumericSortField) sf).getNumericType().name();
          } else {
            return sf.getType().name();
          }
        }).forEach(typeCombo::addItem);
    typeCombo.setEnabled(true);
    orderCombo.setEnabled(true);
  }
}
 
Example 5
Source File: BoundingBoxWindow.java    From Pixie with MIT License 6 votes vote down vote up
/**
 * Create the proper design for the components representing the object
 * attributes and populate the combo boxes with the data defined in the
 * database.
 *
 * @param selectedNode the list of object attributes, including: the list of
 * types, the list of classes, the list of values
 * @param attribute the combo box for which the attribute is initialized
 */
public void initAttributesComponents(CustomTreeNode selectedNode, JComboBox attribute) {
    if (selectedNode == null) {
        return;
    }

    List<String> typeAttrib = selectedNode.getChildren();

    attribute.removeAllItems();

    if ((typeAttrib != null) && (!typeAttrib.isEmpty())) {
        // set the attributes of the combo boxes
        typeAttrib.stream().forEach(objType -> attribute.addItem(Utils.capitalize(objType)));
    }

    attribute.repaint();
}
 
Example 6
Source File: EditOneMotionObjectPanel.java    From opensim-gui with Apache License 2.0 6 votes vote down vote up
private void populateBodyList(final FrameList frameList, JComboBox comboBox) {
    comboBox.removeAllItems();
    FrameIterator bi = frameList.begin();
    ArrayList<String> frameNames = new ArrayList<String>();
    while(!bi.equals(frameList.end())){
          if (PhysicalFrame.safeDownCast(bi.__deref__())!= null){
              frameNames.add(bi.getName());
          }
         bi.next();
    }
    String[] bNames = new String[frameNames.size()];

    for(int i=0; i<frameNames.size(); i++){
        bNames[i]=frameNames.get(i);
        comboBox.addItem(frameNames.get(i));
    }
    comboBox.setModel(new javax.swing.DefaultComboBoxModel(bNames));
}
 
Example 7
Source File: FrmSectionPlot.java    From MeteoInfo with GNU Lesser General Public License v3.0 5 votes vote down vote up
private void updateEndDimSetS(JComboBox CB1, JComboBox CB2) {
    CB2.removeAllItems();
    for (int i = 0; i < CB1.getItemCount(); i++) {
        CB2.addItem(CB1.getItemAt(i));
    }
    CB2.setSelectedIndex(CB2.getItemCount() - 1);
}
 
Example 8
Source File: DialogAddAlertFilter.java    From zap-extensions with Apache License 2.0 5 votes vote down vote up
private void resetScopeCombo() {
    JComboBox<String> scopeCombo = getScopeCombo();
    scopeCombo.removeAllItems();
    scopeCombo.addItem(SCOPE_GLOBAL);
    for (Context context : Model.getSingleton().getSession().getContexts()) {
        scopeCombo.addItem(context.getName());
    }
}
 
Example 9
Source File: DialogHelper.java    From keystore-explorer with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Populate a JComboBox with signature algorithms depending on the key pair type.
 *
 * @param keyPairType
 * @param privateKey
 * @param jcbSignatureAlgorithm
 * @throws CryptoException
 */
public static void populateSigAlgs(KeyPairType keyPairType, PrivateKey privateKey, JComboBox<SignatureType> jcbSignatureAlgorithm)
		throws CryptoException {

	List<SignatureType> sigAlgs;

	switch (keyPairType) {
	case RSA:
		KeyInfo keyInfo = KeyPairUtil.getKeyInfo(privateKey);
		sigAlgs = SignatureType.rsaSignatureTypes(keyInfo.getSize());
		break;
	case DSA:
		sigAlgs = SignatureType.dsaSignatureTypes();
		break;
	case EC:
	default:
		sigAlgs = SignatureType.ecdsaSignatureTypes();
	}

	jcbSignatureAlgorithm.removeAllItems();

	for (SignatureType sigAlg : sigAlgs) {
		jcbSignatureAlgorithm.addItem(sigAlg);
	}

	// pre-select modern hash algs
	if (sigAlgs.contains(SignatureType.SHA256_RSA)) {
		jcbSignatureAlgorithm.setSelectedItem(SignatureType.SHA256_RSA);
	} else if (sigAlgs.contains(SignatureType.SHA256_ECDSA)) {
		jcbSignatureAlgorithm.setSelectedItem(SignatureType.SHA256_ECDSA);
	} else if (sigAlgs.contains(SignatureType.SHA256_DSA)) {
		jcbSignatureAlgorithm.setSelectedItem(SignatureType.SHA256_DSA);
	} else {
		jcbSignatureAlgorithm.setSelectedIndex(0);
	}
}
 
Example 10
Source File: ItemListControl.java    From LoboBrowser with MIT License 5 votes vote down vote up
public void setItems(final Collection<T> items) {
  final JComboBox<T> comboBox = this.comboBox;
  comboBox.removeAllItems();
  for (final T item : items) {
    comboBox.addItem(item);
  }
}
 
Example 11
Source File: ProfileBaseForm.java    From netbeans with Apache License 2.0 5 votes vote down vote up
protected void fillLayoutCombo(JComboBox layoutCombo) {
    layoutCombo.removeAllItems();
    layoutCombo.addItem(ComboConstants.STRICT);
    layoutCombo.addItem(ComboConstants.LAX);
    layoutCombo.addItem(ComboConstants.LAXTSFIRST);
    layoutCombo.addItem(ComboConstants.LAXTSLAST);        
}
 
Example 12
Source File: ProfileBaseForm.java    From netbeans with Apache License 2.0 5 votes vote down vote up
protected void fillSamlCombo(JComboBox samlVersionCombo) {
    samlVersionCombo.removeAllItems();
    samlVersionCombo.addItem(ComboConstants.SAML_V1010);
    samlVersionCombo.addItem(ComboConstants.SAML_V1011);
    samlVersionCombo.addItem(ComboConstants.SAML_V1110);
    samlVersionCombo.addItem(ComboConstants.SAML_V1111);
    samlVersionCombo.addItem(ComboConstants.SAML_V2011);
}
 
Example 13
Source File: ProfileBaseForm.java    From netbeans with Apache License 2.0 5 votes vote down vote up
protected void fillKeySize(JComboBox keySizeCombo, boolean publicKey) {
    keySizeCombo.removeAllItems();
    if (publicKey) {
        keySizeCombo.addItem(ComboConstants.NONE);
        keySizeCombo.addItem(ComboConstants.ISSUED_KEYSIZE_1024);
        keySizeCombo.addItem(ComboConstants.ISSUED_KEYSIZE_2048);
        keySizeCombo.addItem(ComboConstants.ISSUED_KEYSIZE_3072);
    } else {
        keySizeCombo.addItem(ComboConstants.ISSUED_KEYSIZE_128);
        keySizeCombo.addItem(ComboConstants.ISSUED_KEYSIZE_192);
        keySizeCombo.addItem(ComboConstants.ISSUED_KEYSIZE_256);
    }
}
 
Example 14
Source File: ComboBoxTableCellEditor.java    From netbeans with Apache License 2.0 5 votes vote down vote up
public final void setItems (Object [] items)
{

    JComboBox cb = getComboBox ();
    cb.removeAllItems ();
    final int n = (items != null  ?  items.length  :  0);
    for  (int i = 0; i < n; i++)
    {
        cb.addItem (items [i]);
    }

}
 
Example 15
Source File: UI.java    From netbeans with Apache License 2.0 5 votes vote down vote up
public static void setItems(JComboBox comboBox, Object[] items) {
    Object selected = comboBox.getSelectedItem();
    comboBox.removeAllItems();

    for (int i = 0; i < items.length; i++) {
        comboBox.insertItemAt(items[i], i);
    }
    if (items.length > 0) {
        comboBox.setSelectedIndex(0);
    }
    if (selected != null) {
        comboBox.setSelectedItem(selected);
    }
}
 
Example 16
Source File: SendEMailDialog.java    From tn5250j with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Set the combo box items to the string token from to.
 * The separator is a '|' character.
 *
 * @param to
 * @param boxen
 */
private void setToCombo(String to, JComboBox boxen) {

	StringTokenizer tokenizer = new StringTokenizer(to, "|");

	boxen.removeAllItems();

	while (tokenizer.hasMoreTokens()) {
		boxen.addItem(tokenizer.nextToken());
	}
}
 
Example 17
Source File: FormManagerPanel.java    From software-demo with MIT License 5 votes vote down vote up
/**
 * 初始化
 * @param materialsComboBox
 * @param yearComboBox
 * @param monthComBox1 
 * @param monthComBox2
 */
public void init(JComboBox materialsComboBox, JComboBox yearComboBox, JComboBox monthComBox1, JComboBox monthComBox2) {
	//清空
	materialsComboBox.removeAllItems();
	yearComboBox.removeAllItems();
	monthComBox1.removeAllItems();
	monthComBox2.removeAllItems();
	
	List<Materials> materialList = materialsService.getAllMaterialList();
	if(materialList != null) {
		for (Materials materials : materialList) {
			materialsComboBox.addItem(new ComboxVo(materials.getId(), materials.getMaterialsName()));
		}
	}
	
	List<String> years = materialsSellService.getAllYear();
	if(years != null) {
		for (String year : years) {
			yearComboBox.addItem(year);
		}
	}
	
	for (int i = 1; i <= 12; i++) {
		monthComBox1.addItem(i);
		monthComBox2.addItem(i);
	}
}
 
Example 18
Source File: FrmOneDim.java    From MeteoInfo with GNU Lesser General Public License v3.0 5 votes vote down vote up
private void updateEndDimSetS(JComboBox CB1, JComboBox CB2) {
    CB2.removeAllItems();
    for (int i = 0; i < CB1.getItemCount(); i++) {
        CB2.addItem(CB1.getItemAt(i));
    }
    CB2.setSelectedIndex(CB2.getItemCount() - 1);
}
 
Example 19
Source File: Visualisation.java    From chipster with MIT License 4 votes vote down vote up
public static <T> void fillComboBox(JComboBox<T> box, T[] content) {
	box.removeAllItems();
	for (T o : content) {
		box.addItem(o);
	}
}
 
Example 20
Source File: ProfileBaseForm.java    From netbeans with Apache License 2.0 4 votes vote down vote up
protected void fillWssCombo(JComboBox wssCombo) {
    wssCombo.removeAllItems();
    wssCombo.addItem(ComboConstants.WSS10);
    wssCombo.addItem(ComboConstants.WSS11);    
}