javax.swing.DefaultComboBoxModel#removeAllElements ( )源码实例Demo

下面列出了javax.swing.DefaultComboBoxModel#removeAllElements ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: openAGV   文件: EditDriveOrderPanel.java
/**
 * Aktualisiert den Inhalt der ComboBox mit den Aktionen. Wird aufgerufen,
 * wenn in der ComboBox mit den Stationen ein anderes Element ausgewählt
 * wurde.
 *
 * @param evt das auslösende Ereignis
 */
private void locationComboBoxActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_locationComboBoxActionPerformed
  DefaultComboBoxModel<String> model
      = (DefaultComboBoxModel<String>) actionComboBox.getModel();
  model.removeAllElements();

  getSelectedLocation().ifPresent(location -> {
    LocationTypeModel type = location.getLocationType();
    StringSetProperty p = type.getPropertyAllowedOperations();
    for (String item : new ArrayList<>(type.getPropertyAllowedOperations().getItems())) {
      model.addElement(item);
    }

    if (model.getSize() > 0) {
      actionComboBox.setSelectedIndex(0);
    }
  });
}
 
源代码2 项目: arcusplatform   文件: LoginDialog.java
protected void onShow() {
   List<OculusSession> recentSessions = ServiceLocator.getInstance(SessionController.class).listRecentSessions();
   if(!lastSessions.equals(recentSessions)) {
      lastSessions = recentSessions;
      DefaultComboBoxModel<OculusSession> model = ((DefaultComboBoxModel<OculusSession>) serviceUri.getModel());
      model.removeAllElements();
      for(OculusSession hau: ServiceLocator.getInstance(SessionController.class).listRecentSessions()) {
         model.addElement(hau);
      }
   }

   if(username.getText().isEmpty()) {
      username.requestFocusInWindow();
   }
   else {
      password.requestFocusInWindow();
   }
}
 
源代码3 项目: netbeans   文件: DirectorySelectorCombo.java
private void changeModel() {
  DefaultComboBoxModel model = (DefaultComboBoxModel)fileMRU.getModel();
  model.removeAllElements();
  if (isShowWelcome()) {
    model.addElement(new StringComboListElement(getWelcomeText(), true));
  }
  model.addElement(new ComboListElement(getNoneText()) {
    public void onSelection() {
      validSelection = false;
    }
  });
  JSeparator separ = new JSeparator();
  model.addElement(separ);
  model.addElement(new ComboListElement(getActionText()) {
    public void onSelection() {
      validSelection = false;
      browseFiles();
    }
  });
}
 
源代码4 项目: gate-core   文件: XgappUpgradeSelector.java
@Override
@SuppressWarnings("unchecked")
public Component getTableCellEditorComponent(JTable table, Object value, boolean isSelected, int row, int column) {
  JComboBox<UpgradeXGAPP.UpgradePath.UpgradeStrategy> combo = (JComboBox)super.getTableCellEditorComponent(table, value, isSelected, row, column);
  DefaultComboBoxModel<UpgradeXGAPP.UpgradePath.UpgradeStrategy> model = (DefaultComboBoxModel)combo.getModel();
  model.removeAllElements();
  if(((String)table.getValueAt(row, 0)).startsWith("<html>")) {
    // directory plugin
    model.addElement(UpgradeXGAPP.UpgradePath.UpgradeStrategy.UPGRADE);
    model.addElement(UpgradeXGAPP.UpgradePath.UpgradeStrategy.PLUGIN_ONLY);
    model.addElement(UpgradeXGAPP.UpgradePath.UpgradeStrategy.SKIP);
  } else {
    // old $gatehome$ or existing Maven
    model.addElement(UpgradeXGAPP.UpgradePath.UpgradeStrategy.UPGRADE);
    model.addElement(UpgradeXGAPP.UpgradePath.UpgradeStrategy.SKIP);
  }
  combo.setSelectedItem(value); // which must be one of the available ones
  return combo;
}
 
源代码5 项目: zap-extensions   文件: AttackPanel.java
private void setRecentUrls() {
    if (urlField != null) {
        QuickStartParam quickStartParam = this.getExtensionQuickStart().getQuickStartParam();
        Object currentUrl = urlField.getSelectedItem();
        DefaultComboBoxModel<String> model = getUrlModel();
        model.removeAllElements();
        List<Object> recentUrls = quickStartParam.getRecentUrls();
        for (Object url : recentUrls) {
            if (url != null) {
                model.addElement(url.toString());
            }
        }
        if (currentUrl != null && currentUrl.toString().length() > 0) {
            urlField.setSelectedItem(currentUrl);
        } else {
            urlField.setSelectedItem(DEFAULT_VALUE_URL_FIELD);
        }
    }
}
 
源代码6 项目: xdm   文件: MediaFormatWnd.java
private void addToModel(DefaultComboBoxModel<String> model, List<String> list, String defaultValue,
		JComboBox<String> cmb) {
	model.removeAllElements();
	if (list == null) {
		return;
	}
	for (String s : list) {
		model.addElement(s);
	}
	if (!StringUtils.isNullOrEmptyOrBlank(defaultValue)) {
		cmb.setSelectedItem(defaultValue);
	}
}
 
源代码7 项目: netbeans   文件: ResolveBrokenRuntimePlatform.java
private void updatePlatforms() {
    final SourceLevelQuery.Result slqr = SourceLevelQuery.getSourceLevel2(prj.getProjectDirectory());
    final String sl = slqr.getSourceLevel();
    final SourceLevelQuery.Profile profile = slqr.getProfile();
    final DefaultComboBoxModel<Object> model = (DefaultComboBoxModel<Object>) platforms.getModel();
    model.removeAllElements();
    for (J2SERuntimePlatformProvider pp : prj.getLookup().lookupAll(J2SERuntimePlatformProvider.class)) {
        for (JavaPlatform jp : pp.getPlatformType(new SpecificationVersion(sl), profile)) {
            model.addElement(jp);
        }
    }
}
 
源代码8 项目: gate-core   文件: XgappUpgradeSelector.java
@Override
@SuppressWarnings("unchecked")
public Component getTableCellEditorComponent(JTable table, Object value, boolean isSelected, int row, int column) {
  JComboBox<Version> combo = (JComboBox<Version>)super.getTableCellEditorComponent(table, value, isSelected, row, column);
  DefaultComboBoxModel<Version> model = (DefaultComboBoxModel<Version>)combo.getModel();
  model.removeAllElements();
  UpgradeXGAPP.UpgradePath path = (UpgradeXGAPP.UpgradePath)table.getValueAt(row, -1);
  for(Version v : path.getVersions()) {
    model.addElement(v);
  }
  combo.setSelectedItem(value); // which must be one of the available ones
  return combo;
}
 
private void fillCombo(JsonNode attrNode, DefaultComboBoxModel<NamedItem> comboModel, JComboBox combo) {
    JsonNode valArray = attrNode.path("values");
    comboModel.removeAllElements();
    for (JsonNode val : valArray) {
        comboModel.addElement(new NamedItem(val.get("id").asText(), val.get("name").asText()));
    }
    combo.setModel(comboModel);
    combo.setSelectedItem(new NamedItem(attrNode.path("default").asText(), ""));
}
 
源代码10 项目: mars-sim   文件: TabPanelCareer.java
public void checkRoleChange() {

		List<String> names = getRoleNames();
		
        DefaultComboBoxModel<String> model = (DefaultComboBoxModel<String>) roleComboBox.getModel();
        
        int oldSize = model.getSize();
        
        if (oldSize != names.size()) {
	        // removing old data
	        model.removeAllElements();
	
	        for (String item : names) {
	            model.addElement(item);
	        }
	        // setting model with new data
	        roleComboBox.setModel(model);
        }

		// Prepare role combo box
		String newRole = person.getRole().getType().toString();

		if (!roleCache.equalsIgnoreCase(newRole)) {
			roleCache = newRole;
			roleComboBox.setSelectedItem(roleCache);
			
			String s = person + "'s role has just been changed to " + newRole;
			roleChangeLabel.setText(s);
		}
	}
 
源代码11 项目: gate-core   文件: FeaturesSchemaEditor.java
protected void prepareCombo(JComboBox combo, int row, int column){
  Feature feature = featureList.get(row);
  DefaultComboBoxModel comboModel = (DefaultComboBoxModel)combo.getModel(); 
  comboModel.removeAllElements();
  switch(column){
    case NAME_COL:
      List<String> fNames = new ArrayList<String>();
      if(schema != null && schema.getFeatureSchemaSet() != null){
        Iterator<FeatureSchema> fSchemaIter = schema.getFeatureSchemaSet().iterator();
        while(fSchemaIter.hasNext())
          fNames.add(fSchemaIter.next().getFeatureName());
      }
      if(!fNames.contains(feature.name))fNames.add(feature.name);
      Collections.sort(fNames);
      for(Iterator<String> nameIter = fNames.iterator(); 
          nameIter.hasNext(); 
          comboModel.addElement(nameIter.next()));
      combo.getEditor().getEditorComponent().setBackground(defaultBackground);          
      combo.setSelectedItem(feature.name);
      break;
    case VALUE_COL:
      List<Object> fValues = new ArrayList<Object>();
      if(feature.isSchemaFeature()){
        Set<Object> permValues = schema.getFeatureSchema(feature.name).
          getPermittedValues();
        if(permValues != null) fValues.addAll(permValues);
      }
      if(!fValues.contains(feature.value)) fValues.add(feature.value);
      Collections.sort(fValues, defaultComparator);
      for(Iterator<Object> valIter = fValues.iterator(); 
          valIter.hasNext(); 
          comboModel.addElement(valIter.next()));
      combo.getEditor().getEditorComponent().setBackground(feature.isCorrect() ?
          defaultBackground :
          (feature.isRequired() ? REQUIRED_WRONG : OPTIONAL_WRONG));
      combo.setSelectedItem(feature.value);
      break;
    default: ;
  }
  
}