当前位置: 首页>>代码示例>>Java>>正文


Java DefaultComboBoxModel.addElement方法代码示例

本文整理汇总了Java中javax.swing.DefaultComboBoxModel.addElement方法的典型用法代码示例。如果您正苦于以下问题:Java DefaultComboBoxModel.addElement方法的具体用法?Java DefaultComboBoxModel.addElement怎么用?Java DefaultComboBoxModel.addElement使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在javax.swing.DefaultComboBoxModel的用法示例。


在下文中一共展示了DefaultComboBoxModel.addElement方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: testReactsAndHasChanged

import javax.swing.DefaultComboBoxModel; //导入方法依赖的package包/类
/**
 * Test of class TimeoutValueHandler's ability to toggle whether it reacts and the
 * log of whether it changed.
 */
@Test
public void testReactsAndHasChanged() {
    System.out.println("ReactsAndHasChanged");
    JComboBox<String> comboBox = new JComboBox<String>();
    JSpinner spinner = new JSpinner();
    DefaultComboBoxModel<String> model = new DefaultComboBoxModel<String>();
    model.addElement("s");
    model.addElement("m");
    model.addElement("h");
    model.addElement("d");
    comboBox.setModel(model);
    TimeoutValueHandler handler = new TimeoutValueHandler(spinner, comboBox);
    boolean hasChangedBeforeTest = handler.hasChanged();
    handler.setReacts(true);
    spinner.setValue(11);
    comboBox.setSelectedIndex(2);
    handler.setValue(handler.getTimeout());
    boolean hasChangedAfterInput = handler.hasChanged();
    handler.setHasChanged(false);
    handler.setReacts(false);
    spinner.setValue(27);
    comboBox.setSelectedIndex(1);
    boolean hasChangedAfterStopReact = handler.hasChanged();
    assertTrue(!hasChangedBeforeTest && hasChangedAfterInput && !hasChangedAfterStopReact);
}
 
开发者ID:Skypr,项目名称:BEAST,代码行数:30,代码来源:TimeoutValueHandlerTest.java

示例2: btnProjectActionPerformed

import javax.swing.DefaultComboBoxModel; //导入方法依赖的package包/类
private void btnProjectActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnProjectActionPerformed
    JFileChooser chooser = ProjectChooser.projectChooser();
    int res = chooser.showOpenDialog(SwingUtilities.getWindowAncestor(this));
    if (res == JFileChooser.APPROVE_OPTION) {
        File fil = chooser.getSelectedFile();
        FileObject fo = FileUtil.toFileObject(fil);
        if (fo != null) {
            try {
                Project p = ProjectManager.getDefault().findProject(fo);
                DefaultComboBoxModel model = (DefaultComboBoxModel)comProject.getModel();
                model.addElement(p);
                model.setSelectedItem(p);
                if (EMPTY == model.getElementAt(0)) {
                    model.removeElement(EMPTY);
                }
            } catch (IOException exc) {
                ErrorManager.getDefault().notify(exc);
            }
        }
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:22,代码来源:SelectProjectPanel.java

示例3: ModOptionUI

import javax.swing.DefaultComboBoxModel; //导入方法依赖的package包/类
/**
 * Creates a new {@code ModOptionUI} for the given
 * {@code ModOption}.
 *
 * @param option The {@code ModOption} to make a user interface for
 * @param editable boolean whether user can modify the setting
 */
public ModOptionUI(final ModOption option, boolean editable) {
    super(option, editable);

    DefaultComboBoxModel<FreeColModFile> model
        = new DefaultComboBoxModel<>();
    for (FreeColModFile choice : option.getChoices()) {
        model.addElement(choice);
    }
    this.box = new JComboBox<>();
    this.box.setModel(model);
    this.box.setRenderer(new BoxRenderer());
    if (option.getValue() != null) {
        this.box.setSelectedItem(option.getValue());
    }
    initialize();
}
 
开发者ID:FreeCol,项目名称:freecol,代码行数:24,代码来源:ModOptionUI.java

示例4: getJComboBoxProjectSelector

import javax.swing.DefaultComboBoxModel; //导入方法依赖的package包/类
/**
 * This method initializes jComboBoxProjectSelector	
 * @return javax.swing.JComboBox	
 */
private JComboBox<String> getJComboBoxProjectSelector() {
	if (jComboBoxProjectSelector == null) {
		
		DefaultComboBoxModel<String> comboBoxModel = new DefaultComboBoxModel<String>();
		comboBoxModel.addElement("");
		String[] projectFolders = getGlobalInfo().getProjectSubDirectories();
		if (projectFolders!=null && projectFolders.length>0) {
			for (int i = 0; i < projectFolders.length; i++) {
				comboBoxModel.addElement(projectFolders[i]);	
			}	
		}
		jComboBoxProjectSelector = new JComboBox<String>(comboBoxModel);
		jComboBoxProjectSelector.setPreferredSize(new Dimension(300, 26));
		jComboBoxProjectSelector.setActionCommand("esaProjectSelected");
		jComboBoxProjectSelector.addActionListener(this);
	}
	return jComboBoxProjectSelector;
}
 
开发者ID:EnFlexIT,项目名称:AgentWorkbench,代码行数:23,代码来源:JPanelEmbeddedSystemAgent.java

示例5: populateProjectComboBox

import javax.swing.DefaultComboBoxModel; //导入方法依赖的package包/类
private void populateProjectComboBox() {
	DefaultComboBoxModel<Project> prjBoxMdl = new DefaultComboBoxModel<Project>();
	Iterator<Project> itr = prjToTagToEditedMap.keySet().iterator();
	while (itr.hasNext()) {
		prjBoxMdl.addElement(itr.next());
	}
	projectBox.setModel(prjBoxMdl);
}
 
开发者ID:ser316asu,项目名称:Neukoelln_SER316,代码行数:9,代码来源:EditProjectTagController.java

示例6: itemStateChanged

import javax.swing.DefaultComboBoxModel; //导入方法依赖的package包/类
/**
 * {@inheritDoc}
 */
@Override
public void itemStateChanged(ItemEvent e) {
    // When the unit type changes, we have to reset the role choices
    JComboBox<String> box = this.roleUI.getComponent();
    DefaultComboBoxModel<String> model;
    boolean enable = false;
    UnitType type = (UnitType)this.typeUI.getComponent().getSelectedItem();
    if (type != null && type.hasAbility(Ability.CAN_BE_EQUIPPED)) {
        final Specification spec = type.getSpecification();
        final NationType nt = getOption().getNationType();
        int n = 0;
        model = new DefaultComboBoxModel<>();
        for (String ri : getOption().getRole().getChoices()) {
            Role role = spec.getRole(ri);
            if (role.isAvailableTo(type, nt)) {
                model.addElement(ri);
                n++;
            }
        }
        enable = isEditable() && n > 1;
    } else {
        model = new DefaultComboBoxModel<>(new String[] {
                Specification.DEFAULT_ROLE_ID });
    }
    box.setModel(model);
    box.setEnabled(enable);
}
 
开发者ID:FreeCol,项目名称:freecol,代码行数:31,代码来源:AbstractUnitOptionUI.java

示例7: fillTableCombo

import javax.swing.DefaultComboBoxModel; //导入方法依赖的package包/类
/**
 * Fills the content of <code>tableCombo</code>.
 *
 * @param connection database connection.
 */
private void fillTableCombo(DatabaseConnection connection) {
    DefaultComboBoxModel model = new DefaultComboBoxModel();
    for (J2EEUtils.DBColumnInfo table : J2EEUtils.tableNamesForConnection(connection)) {
        model.addElement(table);
    }
    tableCombo.setModel(model);
    tableCombo.setEnabled(tableCombo.getModel().getSize() != 0);
    tableCombo.setSelectedItem(tableCombo.getSelectedItem());
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:15,代码来源:JPADataImporter.java

示例8: loadUsersList

import javax.swing.DefaultComboBoxModel; //导入方法依赖的package包/类
private void loadUsersList() {
    ArrayList<User> usersList = UserController.getUsersList();
    DefaultComboBoxModel def = (DefaultComboBoxModel) cmb_user.getModel();
    def.removeAllElements();
    if (usersList.size() > 0) {
        for (User user : usersList) {
            if (user.getUserStatus() == 1) {
                def.addElement(user);
            }
        }
    }
}
 
开发者ID:isu3ru,项目名称:java-swing-template,代码行数:13,代码来源:Login.java

示例9: getSkillModel

import javax.swing.DefaultComboBoxModel; //导入方法依赖的package包/类
private DefaultComboBoxModel<UnitType> getSkillModel() {
    IndianNationType ownerType = getOwnerNationType();
    DefaultComboBoxModel<UnitType> skillModel
        = new DefaultComboBoxModel<>();
    for (RandomChoice<UnitType> skill : ownerType.getSkills()) {
        skillModel.addElement(skill.getObject());
    }
    return skillModel;
}
 
开发者ID:FreeCol,项目名称:freecol,代码行数:10,代码来源:EditSettlementDialog.java

示例10: configurationsListChanged

import javax.swing.DefaultComboBoxModel; //导入方法依赖的package包/类
private void configurationsListChanged(@NullAllowed Collection<? extends ProjectConfiguration> configs) {
    LOGGER.log(Level.FINER, "configurationsListChanged: {0}", configs);
    ProjectConfigurationProvider<?> _pcp;
    synchronized (this) {
        _pcp = pcp;
    }
    if (configs == null) {
        EventQueue.invokeLater(new Runnable() {
            public @Override void run() {
                configListCombo.setModel(EMPTY_MODEL);
                configListCombo.setEnabled(false); // possibly redundant, but just in case
            }
        });
    } else {
        final DefaultComboBoxModel model = new DefaultComboBoxModel(configs.toArray());
        if (_pcp != null && _pcp.hasCustomizer()) {
            model.addElement(CUSTOMIZE_ENTRY);
        }
        EventQueue.invokeLater(new Runnable() {
            public @Override void run() {
                configListCombo.setModel(model);
                configListCombo.setEnabled(true);
            }
        });
    }
    if (_pcp != null) {
        activeConfigurationChanged(getActiveConfiguration(_pcp));
    }
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:30,代码来源:ActiveConfigAction.java

示例11: init

import javax.swing.DefaultComboBoxModel; //导入方法依赖的package包/类
private void init() {
    model = new DefaultComboBoxModel();
    btCadastrar.addActionListener(handlerCidades);
    btFechar.addActionListener(handlerCidades);
    EstadoDAO estado = new EstadoDAO();
    List<br.com.secharpe.model.Estados> listEstados = estado.getAll();
    for (br.com.secharpe.model.Estados est : listEstados) {
        model.addElement(est.getSigla());
    }
    cbEstado.setModel(model);
}
 
开发者ID:luandr,项目名称:ProjetoERP,代码行数:12,代码来源:CidadesCadastro.java

示例12: createCookieClassModel

import javax.swing.DefaultComboBoxModel; //导入方法依赖的package包/类
private static ComboBoxModel createCookieClassModel() {
    DefaultComboBoxModel cookieClassModel = new DefaultComboBoxModel();
    for (String fqcn : DataModel.PREDEFINED_COOKIE_CLASSES) {
        String name = DataModel.parseClassName(fqcn);
        cookieClassModel.addElement(name);
    }
    return cookieClassModel;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:9,代码来源:ActionTypePanel.java

示例13: getJComboBoxClusterShape

import javax.swing.DefaultComboBoxModel; //导入方法依赖的package包/类
/**
 * Returns the JComboBox for the possible cluster shapes.
 * @return the JComboBox for the possible cluster shapes
 */
private JComboBoxWide<String> getJComboBoxClusterShape() {
	
	DefaultComboBoxModel<String> cbmShape = new DefaultComboBoxModel<String>(); 
	cbmShape.addElement(GeneralGraphSettings4MAS.SHAPE_ELLIPSE);
	cbmShape.addElement(GeneralGraphSettings4MAS.SHAPE_RECTANGLE);
	cbmShape.addElement(GeneralGraphSettings4MAS.SHAPE_ROUND_RECTANGLE);
	cbmShape.addElement(GeneralGraphSettings4MAS.SHAPE_REGULAR_POLYGON);
	cbmShape.addElement(GeneralGraphSettings4MAS.SHAPE_REGULAR_STAR);
	
	JComboBoxWide<String> jComboBoxClusterShape = new JComboBoxWide<String>(cbmShape);
	jComboBoxClusterShape.setPreferredSize(new Dimension(50, 26));
	return jComboBoxClusterShape;
}
 
开发者ID:EnFlexIT,项目名称:AgentWorkbench,代码行数:18,代码来源:ComponentTypeDialog.java

示例14: SelectOptionUI

import javax.swing.DefaultComboBoxModel; //导入方法依赖的package包/类
/**
 * Creates a new {@code SelectOptionUI} for the given
 * {@code SelectOption}.
 *
 * @param option The {@code SelectOption} to make a user
 *     interface for.
 * @param editable Whether user can modify the setting.
 */
public SelectOptionUI(final SelectOption option, boolean editable) {
    super(option, editable);

    DefaultComboBoxModel<String> model = new DefaultComboBoxModel<>();
    for (String string : option.getItemValues().values()) {
        model.addElement(option.localizeLabels() ? Messages.message(string)
            : string);
    }

    box.setModel(model);
    box.setSelectedIndex(option.getValue());

    initialize();
}
 
开发者ID:FreeCol,项目名称:freecol,代码行数:23,代码来源:SelectOptionUI.java

示例15: prepareCombo

import javax.swing.DefaultComboBoxModel; //导入方法依赖的package包/类
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: ;
  }
  
}
 
开发者ID:GateNLP,项目名称:gate-core,代码行数:42,代码来源:FeaturesSchemaEditor.java


注:本文中的javax.swing.DefaultComboBoxModel.addElement方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。