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


Java MutableComboBoxModel.getSize方法代码示例

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


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

示例1: getSuitesComboBox

import javax.swing.MutableComboBoxModel; //导入方法依赖的package包/类
/**
 * Returns <code>JComboBox</code> containing all suites. Also see
 * {@link #addUserSuite}.
 */
public static JComboBox getSuitesComboBox() {
    MutableComboBoxModel model = new SuiteListModel(userSuites);
    Project[] projects = OpenProjects.getDefault().getOpenProjects();
    for (int i = 0; i < projects.length; i++) {
        String suiteDir = SuiteUtils.getSuiteDirectoryPath(projects[i]);
        if (suiteDir != null) {
            model.addElement(suiteDir);
        }
    }
    JComboBox suiteCombo = new JComboBox(model);
    if (model.getSize() > 0) {
        suiteCombo.setSelectedIndex(0);
    }
    return suiteCombo;
}
 
开发者ID:apache,项目名称:incubator-netbeans,代码行数:20,代码来源:PlatformComponentFactory.java

示例2: setModels

import javax.swing.MutableComboBoxModel; //导入方法依赖的package包/类
/**
 * Sets the drop combo box items of the model list
 * 
 * @param modelIDs
 *            id array
 */
public void setModels(int[] modelIDs) {
	String[] modelNames = new String[modelIDs.length];
	for (int i = 0; i < modelIDs.length; i++) {
		modelNames[i] = "Model " + modelIDs[i];
		// cbModelList.addItem(modelNames[i]);
	}

	MutableComboBoxModel<String> model = (MutableComboBoxModel<String>) cbModelList.getModel();
	cbModelList.removeAllItems();
	for (int i = 0; i < model.getSize(); i++) {
		model.removeElementAt(i);
	}

	for (int i = 0; i < modelIDs.length; i++) {
		cbModelList.addItem(modelNames[i]);
		btnOk.setEnabled(true);
		rdbtnCompare.setEnabled(true);
		rdbtnModel.setEnabled(true);
	}
	resetButtons();
}
 
开发者ID:noah95,项目名称:ezrlc,代码行数:28,代码来源:RectPlotAddMeasurementWindow.java

示例3: setModels

import javax.swing.MutableComboBoxModel; //导入方法依赖的package包/类
/**
 * Sets the drop combo box items of the model list
 * 
 * @param modelIDs
 *            ids
 */
public void setModels(int[] modelIDs) {
	String[] modelNames = new String[modelIDs.length];
	for (int i = 0; i < modelIDs.length; i++) {
		modelNames[i] = "Model " + modelIDs[i];
		// cbModelList.addItem(modelNames[i]);
	}

	MutableComboBoxModel<String> model = (MutableComboBoxModel<String>) cbModelList.getModel();
	cbModelList.removeAllItems();
	for (int i = 0; i < model.getSize(); i++) {
		model.removeElementAt(i);
	}

	for (int i = 0; i < modelIDs.length; i++) {
		cbModelList.addItem(modelNames[i]);
		rdbtnModel.setEnabled(true);
		btnOk.setEnabled(true);
	}
	rdbtnFile.setSelected(true);
	rdbtnModel.setSelected(false);
}
 
开发者ID:noah95,项目名称:ezrlc,代码行数:28,代码来源:SmithChartAddMeasurementWindow.java

示例4: setSelectedBean

import javax.swing.MutableComboBoxModel; //导入方法依赖的package包/类
/**
 * Sets the bean on this editor.
 * If an editor of the same class is found, it is selected an modified to match
 * If no bean of this type is found, it is added to the list
 *
 * @param bean the bean
 */
public void setSelectedBean(final IBean bean) {
  final MutableComboBoxModel<IBean> model = (MutableComboBoxModel<IBean>) selector.getModel();
  final DefaultComboBoxModel<IBean> newModel = new DefaultComboBoxModel<>();
  boolean found = false;
  for (int i = 0; i < model.getSize(); i++) {
    final IBean candidate = model.getElementAt(i);
    if (candidate.equals(bean)) {
      found = true;
      newModel.addElement(bean);
    } else {
      newModel.addElement(candidate);
    }
  }
  if (found) {
    selector.setModel(newModel);
  } else {
    model.addElement(bean);
  }
  selector.setSelectedItem(bean);
  updateView();
}
 
开发者ID:triplea-game,项目名称:triplea,代码行数:29,代码来源:SelectAndViewEditor.java

示例5: insertIntoCombo

import javax.swing.MutableComboBoxModel; //导入方法依赖的package包/类
/**
 * Insert the given item into the combo box, and set it as first selected
 * item.  If the item already exists, it is removed, so there are no
 * duplicates.
 * @param combo
 * @param item the item to insert. if it's null, then nothing is inserted
 */
public static void insertIntoCombo(JComboBox combo, Object item) {
	if(item == null) {
		return;
	}
	MutableComboBoxModel model = (MutableComboBoxModel) combo.getModel();
	if (model.getSize() == 0) {
		model.insertElementAt(item, 0);
		return;
	}

	Object o = model.getElementAt(0);
	if (o.equals(item)) {
		return;
	}
	model.removeElement(item);
	model.insertElementAt(item, 0);
	combo.setSelectedIndex(0);
}
 
开发者ID:jindrapetrik,项目名称:jpexs-decompiler,代码行数:26,代码来源:ActionUtils.java

示例6: replaceBoxModelValues

import javax.swing.MutableComboBoxModel; //导入方法依赖的package包/类
private void replaceBoxModelValues(MutableComboBoxModel mmodel, List<String> newPossibleValues) {
    try {
        while (mmodel.getSize() > 0)
            mmodel.removeElementAt(0);
    } catch (Exception e) {
        // ignore weird index out of bounds exceptions
    }
    for (String value : newPossibleValues) {
        mmodel.addElement(value);
    }
}
 
开发者ID:ytus,项目名称:findbugs-all-the-bugs,代码行数:12,代码来源:AbstractSwingGuiCallback.java


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