下面列出了javax.swing.JComboBox#removeAllItems ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。
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));
}
/**
* 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();
}
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);
}
}
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;
}
}
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);
}
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);
}
}
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);
}
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);
}
/**
* 初始化
* @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);
}
}
/**
* 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());
}
}
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);
}
}
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]);
}
}
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);
}
}
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);
}
protected void fillLayoutCombo(JComboBox layoutCombo) {
layoutCombo.removeAllItems();
layoutCombo.addItem(ComboConstants.STRICT);
layoutCombo.addItem(ComboConstants.LAX);
layoutCombo.addItem(ComboConstants.LAXTSFIRST);
layoutCombo.addItem(ComboConstants.LAXTSLAST);
}
public void setItems(final Collection<T> items) {
final JComboBox<T> comboBox = this.comboBox;
comboBox.removeAllItems();
for (final T item : items) {
comboBox.addItem(item);
}
}
/**
* 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);
}
}
private void resetScopeCombo() {
JComboBox<String> scopeCombo = getScopeCombo();
scopeCombo.removeAllItems();
scopeCombo.addItem(SCOPE_GLOBAL);
for (Context context : Model.getSingleton().getSession().getContexts()) {
scopeCombo.addItem(context.getName());
}
}
protected void fillWssCombo(JComboBox wssCombo) {
wssCombo.removeAllItems();
wssCombo.addItem(ComboConstants.WSS10);
wssCombo.addItem(ComboConstants.WSS11);
}
public static <T> void fillComboBox(JComboBox<T> box, T[] content) {
box.removeAllItems();
for (T o : content) {
box.addItem(o);
}
}