本文整理汇总了Java中javax.swing.JComboBox.removeAllItems方法的典型用法代码示例。如果您正苦于以下问题:Java JComboBox.removeAllItems方法的具体用法?Java JComboBox.removeAllItems怎么用?Java JComboBox.removeAllItems使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javax.swing.JComboBox
的用法示例。
在下文中一共展示了JComboBox.removeAllItems方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: setItems
import javax.swing.JComboBox; //导入方法依赖的package包/类
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);
}
}
示例2: initAttributesComponents
import javax.swing.JComboBox; //导入方法依赖的package包/类
/**
* 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();
}
示例3: updateCombos
import javax.swing.JComboBox; //导入方法依赖的package包/类
private void updateCombos(boolean selectDefaults) {
// In case you go back and choose a different script:
Iterator<TargetDescriptor> descriptors = targetDescs.iterator();
for (JComboBox combo : combos) {
TargetDescriptor desc = descriptors.next();
combo.removeAllItems();
for (String name : targetNames) {
combo.addItem(name);
}
if (selectDefaults) {
selectItem(combo, desc.getDefaultTargets(), false); // NOI18N
}
}
}
示例4: getSuportedLayouts
import javax.swing.JComboBox; //导入方法依赖的package包/类
/**
* Returns the suported Layouts from selected factory
*/
public void getSuportedLayouts(JComboBox cb, JComboBox r){
Vector layoutOptionsVector = ((GraphFactory)bType.getSelectedItem()).getSupportedLayouts();
r.removeAllItems();
/*if(layoutOptionsVector.size()==0)
layoutOptionsVector.add(new CircleLayout(null));*/
Iterator iterator = layoutOptionsVector.iterator();
Object obj;
while (iterator.hasNext()){
obj = iterator.next();
r.addItem(obj);
}
SpecialGraphWindow.getInstance().setVisible(true);
}
示例5: initGui
import javax.swing.JComboBox; //导入方法依赖的package包/类
public void initGui() {
enabler = new JCheckBox("Enable What-If analysis");
enabler.setToolTipText("Enable or disable What-If analysis");
enablerPanel = new JPanel(new BorderLayout());
enablerPanel.add(enabler, BorderLayout.WEST);
upperPanel = new JPanel(new BorderLayout());
chooserPanel = new JPanel();
tb = new TitledBorder("Parameter selection for the control of repeated executions");
chooserPanel.setBorder(tb);
chooser = new JComboBox(parameters);
chooser.setPreferredSize(DIM_BUTTON_L);
chooser.setToolTipText("Choose the what-if analysis to be performed");
chooserPanel.add(chooser, BorderLayout.NORTH);
JLabel description = new JLabel(PARAMETRIC_ANALYSIS_DESCRIPTION);
JLabel Warning = new JLabel (HTML_START + HTML_FONT_TITLE + "WARNING: "+ HTML_FONT_TIT_END + HTML_FONT_NORM
+ "Enabling What-If analysis will disable all statistical outputs." + HTML_FONT_NOR_END + HTML_END);
JPanel northPanel = new JPanel(new BorderLayout());
northPanel.setBorder(new EmptyBorder(0, 0, 15, 0));
northPanel.add(description, "Center");
northPanel.add(Warning, "South");
northPanel.add(enablerPanel, "East");
upperPanel.add(northPanel, BorderLayout.NORTH);
upperPanel.add(chooserPanel, BorderLayout.SOUTH);
this.setLayout(new BorderLayout());
this.setBorder(new EmptyBorder(20, 20, 20, 20));
chooser.removeAllItems();
ParametricAnalysisChecker pac = new ParametricAnalysisChecker(cd, sd, simd);
if (!pac.canBeEnabled()) {
enabler.setEnabled(false);
parameterOptionPanel = createPanel(null);
simd.setParametricAnalysisModel(null);
simd.setParametricAnalysisEnabled(false);
} else {
enabler.setEnabled(true);
enabler.setSelected(simd.isParametricAnalysisEnabled());
ParametricAnalysisDefinition pad = simd.getParametricAnalysisModel();
parameters = pac.getRunnableParametricAnalysis();
for (String parameter : parameters) {
chooser.addItem(parameter);
}
String temp = parameters[0];
if (pad == null) {
pad = ParametricAnalysisModelFactory.createParametricAnalysisModel(temp, cd, sd, simd);
simd.setParametricAnalysisModel(pad);
} else {
int code = pad.checkCorrectness(true); //check correctness of the PAD and if it is possible corrects it
if (code != 2) {
chooser.setSelectedItem(pad.getType());
} else { //the old type of parametric analysis is no more available
pad = ParametricAnalysisModelFactory.createParametricAnalysisModel(temp, cd, sd, simd);
simd.setParametricAnalysisModel(pad);
}
}
parameterOptionPanel = createPanel(pad);
}
parameterOptionPanel.setBorder(new EmptyBorder(10, 0, 0, 0));
this.add(upperPanel, BorderLayout.NORTH);
this.add(parameterOptionPanel, BorderLayout.CENTER);
this.setEnabled(enabler.isSelected());
}
示例6: initGui
import javax.swing.JComboBox; //导入方法依赖的package包/类
public void initGui() {
enabler = new JCheckBox("Enable what-if analysis");
enabler.setToolTipText("Enable or disable what-if analysis");
enablerPanel = new JPanel(new BorderLayout());
enablerPanel.add(enabler, BorderLayout.WEST);
//enablerPanel.setBorder(new EmptyBorder(30,10,10,10));
upperPanel = new JPanel(new BorderLayout());
chooserPanel = new JPanel();
tb = new TitledBorder("Parameter selection for the control of repeated executions");
chooserPanel.setBorder(tb);
chooser = new JComboBox(parameters);
chooser.setPreferredSize(DIM_BUTTON_L);
chooser.setToolTipText("Choose the what-if analysis to be performed");
chooserPanel.add(chooser, BorderLayout.NORTH);
JLabel description = new JLabel(PARAMETRIC_ANALYSIS_DESCRIPTION);
JPanel northPanel = new JPanel(new BorderLayout());
northPanel.setBorder(new EmptyBorder(0, 0, 15, 0));
northPanel.add(description, "Center");
northPanel.add(enablerPanel, "East");
upperPanel.add(northPanel, BorderLayout.NORTH);
upperPanel.add(chooserPanel, BorderLayout.SOUTH);
this.setLayout(new BorderLayout());
this.setBorder(new EmptyBorder(20, 20, 20, 20));
chooser.removeAllItems();
ParametricAnalysisChecker pac = new ParametricAnalysisChecker(cd, sd, simd);
if (!pac.canBeEnabled()) {
enabler.setEnabled(false);
parameterOptionPanel = createPanel(null);
simd.setParametricAnalysisModel(null);
simd.setParametricAnalysisEnabled(false);
} else {
enabler.setEnabled(true);
enabler.setSelected(simd.isParametricAnalysisEnabled());
ParametricAnalysisDefinition pad = simd.getParametricAnalysisModel();
parameters = pac.getRunnableParametricAnalysis();
for (String parameter : parameters) {
chooser.addItem(parameter);
}
String temp = parameters[0];
if (pad == null) {
pad = ParametricAnalysisModelFactory.createParametricAnalysisModel(temp, cd, sd, simd);
simd.setParametricAnalysisModel(pad);
} else {
int code = pad.checkCorrectness(true); //check correctness of the PAD and if it is possible corrects it
if (code != 2) {
chooser.setSelectedItem(pad.getType());
} else { //the old type of parametric analysis is no more avaible
pad = ParametricAnalysisModelFactory.createParametricAnalysisModel(temp, cd, sd, simd);
simd.setParametricAnalysisModel(pad);
}
}
parameterOptionPanel = createPanel(pad);
}
parameterOptionPanel.setBorder(new EmptyBorder(10, 0, 0, 0));
this.add(upperPanel, BorderLayout.NORTH);
this.add(parameterOptionPanel, BorderLayout.CENTER);
this.setEnabled(enabler.isSelected());
}