當前位置: 首頁>>代碼示例>>Java>>正文


Java JComboBox.addItem方法代碼示例

本文整理匯總了Java中javax.swing.JComboBox.addItem方法的典型用法代碼示例。如果您正苦於以下問題:Java JComboBox.addItem方法的具體用法?Java JComboBox.addItem怎麽用?Java JComboBox.addItem使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在javax.swing.JComboBox的用法示例。


在下文中一共展示了JComboBox.addItem方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: Ed

import javax.swing.JComboBox; //導入方法依賴的package包/類
public Ed(RestrictCommands piece) {

      box = new JPanel();
      box.setLayout(new BoxLayout(box, BoxLayout.Y_AXIS));

      name = new StringConfigurer(null, "Description:  ", piece.name);
      box.add(name.getControls());

      actionOption = new JComboBox();
      actionOption.addItem(HIDE);
      actionOption.addItem(DISABLE);
      actionOption.setSelectedIndex((piece.action.equals(HIDE)) ? 0 : 1);
      Box b = Box.createHorizontalBox();
      b.add(new JLabel("Restriction:  "));
      b.add(actionOption);
      box.add(b);

      propertyMatch = new PropertyExpressionConfigurer(null, "Restrict when properties match:  ", piece.propertyMatch, Decorator.getOutermost(piece));
      box.add(propertyMatch.getControls());

      watchKeys = new NamedKeyStrokeArrayConfigurer(null, "Restrict these Key Commands  ", piece.watchKeys);
      box.add(watchKeys.getControls());

    }
 
開發者ID:ajmath,項目名稱:VASSAL-src,代碼行數:25,代碼來源:RestrictCommands.java

示例2: populateComboBox

import javax.swing.JComboBox; //導入方法依賴的package包/類
/**
 * Populates a combobox with an array of strings and selects the default
 *
 * @param combobox combobox to be populated
 * @param items    array of strings to be added to the combobox
 * @param selected the default selected item
 */
private void populateComboBox(JComboBox combobox, Collection<String> items, String selected) {
    String item;
    Iterator<String> i = items.iterator();
    int index = 0;
    while (i.hasNext()) {
        item = (String) i.next();
        combobox.addItem(item);
        if (item.equals(selected)) {
            combobox.setSelectedIndex(index);
        }
        index++;
    }
}
 
開發者ID:YcheCourseProject,項目名稱:DIA-Umpire-Maven,代碼行數:21,代碼來源:AlignWindow.java

示例3: getCellEditor

import javax.swing.JComboBox; //導入方法依賴的package包/類
@Override
public java.awt.Component getCellEditor(BitWidth value) {
	JComboBox<BitWidth> combo = new JComboBox<BitWidth>(choices);
	if (value != null) {
		int wid = value.getWidth();
		if (wid <= 0 || wid > prefab.length) {
			combo.addItem(value);
		}
		combo.setSelectedItem(value);
	}
	return combo;
}
 
開發者ID:LogisimIt,項目名稱:Logisim,代碼行數:13,代碼來源:BitWidth.java

示例4: createComboTransf

import javax.swing.JComboBox; //導入方法依賴的package包/類
private void createComboTransf() {
	transfs = new JComboBox();
	transfs.setToolTipText(TRANSF_COMBO);
	transfs.addItem("Logarithmic");
	transfs.addItem("Mix - Max");
	transfs.addItem("z-score (Standard Deviation)");
}
 
開發者ID:HOMlab,項目名稱:QN-ACTR-Release,代碼行數:8,代碼來源:StatsPanel.java

示例5: 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
        }
    }
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:15,代碼來源:TargetMappingPanel.java

示例6: createPrintForEditor

import javax.swing.JComboBox; //導入方法依賴的package包/類
private TableCellEditor createPrintForEditor() {
    JComboBox box = new JComboBox();
    box.addItem(null);
    box.addItem(PRINT_FOR_ALL);
    box.addItem(PRINT_FOR_HAVE_CHILDS);
    box.addItem(PRINT_FOR_HAVE_NO_CHILDS);
    return new DefaultCellEditor(box);
}
 
開發者ID:Vitaliy-Yakovchuk,項目名稱:ramus,代碼行數:9,代碼來源:TableCellEditorFactory.java

示例7: createParameterCombo

import javax.swing.JComboBox; //導入方法依賴的package包/類
private JComboBox createParameterCombo(String operatorName, PropertyTable propertyTable) {
	JComboBox combo = new JComboBox();

	Operator operator = process.getOperator((String) operatorCombo.getSelectedItem());
	if (operator != null) {
		Iterator<ParameterType> i = operator.getParameters().getParameterTypes().iterator();
		while (i.hasNext()) {
			combo.addItem(i.next().getKey());
		}
	}

	if (combo.getItemCount() == 0) {
		combo.addItem("no parameters");
	}

	combo.addItemListener(new ItemListener() {

		@Override
		public void itemStateChanged(ItemEvent e) {
			fireParameterChangedEvent();
			fireEditingStopped();
		}
	});

	combo.setSelectedIndex(0);

	return combo;
}
 
開發者ID:transwarpio,項目名稱:rapidminer,代碼行數:29,代碼來源:ParameterValueKeyCellEditor.java

示例8: buildConnectingPanel

import javax.swing.JComboBox; //導入方法依賴的package包/類
public JPanel buildConnectingPanel() {
    JPanel connectPanel = new JPanel();
    connectPanel.setLayout(new ColumnLayout());

    JPanel protoPanel = new JPanel();
    JLabel protoLabel = new JLabel("Protocol");
    JComboBox protocol = new JComboBox();
    protocol.addItem("SMTP");
    protocol.addItem("IMAP");
    protocol.addItem("Other...");
    protoPanel.add(protoLabel);
    protoPanel.add(protocol);

    JPanel attachmentPanel = new JPanel();
    JLabel attachmentLabel = new JLabel("Attachments");
    JComboBox attach = new JComboBox();
    attach.addItem("Download Always");
    attach.addItem("Ask size > 1 Meg");
    attach.addItem("Ask size > 5 Meg");
    attach.addItem("Ask Always");
    attachmentPanel.add(attachmentLabel);
    attachmentPanel.add(attach);

    JCheckBox autoConn = new JCheckBox("Auto Connect");
    JCheckBox compress = new JCheckBox("Use Compression");
    autoConn.setSelected(true);

    connectPanel.add(protoPanel);
    connectPanel.add(attachmentPanel);
    connectPanel.add(autoConn);
    connectPanel.add(compress);
    return connectPanel;
}
 
開發者ID:lambdalab-mirror,項目名稱:jdk8u-jdk,代碼行數:34,代碼來源:MetalworksPrefs.java

示例9: LinesTable

import javax.swing.JComboBox; //導入方法依賴的package包/類
/**
 * Builds a new LinesTable
 */
public LinesTable() {
	super(new LinesTableModel());
	setDefaultRenderer(Color.class, new ColorCellEditor());
	setDefaultRenderer(String.class, ComboBoxCellEditor.getRendererInstance());
	// Sets column sizes
	getColumnModel().getColumn(0).setMaxWidth(30);
	getColumnModel().getColumn(1).setPreferredWidth(80);
	getColumnModel().getColumn(2).setPreferredWidth(80);
	setRowHeight(18);

	// Creates class editors (one is for utilizations)
	JComboBox classCombo = new JComboBox();
	// Null elements
	classCombo.addItem("");
	// Aggregate measures
	classCombo.addItem(AGGREGATE);
	for (int i = 0; i < model.getClasses(); i++) {
		classCombo.addItem(model.getClassNames()[i]);
	}

	// Creates station editor
	JComboBox stationsCombo = new JComboBox();
	JComboBox uStationsCombo = new JComboBox();
	stationsCombo.addItem("");
	uStationsCombo.addItem("");
	stationsCombo.addItem(AGGREGATE);
	uStationsCombo.addItem(ExactConstants.GRAY_S + AGGREGATE + ExactConstants.GRAY_E);
	for (int i = 0; i < model.getStations(); i++) {
		stationsCombo.addItem(model.getStationNames()[i]);
		uStationsCombo.addItem(model.getStationNames()[i]);
	}

	// Creates editors
	classEditor = new ComboEditor(classCombo);
	uStationsEditor = new ComboEditor(uStationsCombo);
	stationsEditor = new ComboEditor(stationsCombo);
}
 
開發者ID:HOMlab,項目名稱:QN-ACTR-Release,代碼行數:41,代碼來源:GraphPanel.java

示例10: 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);
 }
 
開發者ID:guilhebl,項目名稱:routerapp,代碼行數:17,代碼來源:SpecialGraphWindow.java

示例11: getTableCellEditor

import javax.swing.JComboBox; //導入方法依賴的package包/類
@Override
public TableCellEditor getTableCellEditor(final Engine engine,
                                          final AccessRules rules, final Attribute attribute) {
    final JComboBox box = new JComboBox();
    box.setRenderer(comboBoxRenderer);

    for (Stroke stroke : LineStyleChooser.getStrokes()) {
        box.addItem(stroke);
    }

    return new DefaultCellEditor(box) {
        private Pin pin;

        @Override
        public boolean stopCellEditing() {
            if (box.getSelectedItem() instanceof Stroke) {
                ((Journaled) engine).startUserTransaction();
                apply((BasicStroke) box.getSelectedItem(), pin);
                return super.stopCellEditing();
            }
            return false;
        }

        @Override
        public Component getTableCellEditorComponent(JTable table,
                                                     Object value, boolean isSelected, int row, int column) {
            pin = (Pin) ((MetadataGetter) table).getMetadata();
            return super.getTableCellEditorComponent(table, value,
                    isSelected, row, column);
        }
    };
}
 
開發者ID:Vitaliy-Yakovchuk,項目名稱:ramus,代碼行數:33,代碼來源:LineStyleAttributePlugin.java

示例12: populateTypeComboBox

import javax.swing.JComboBox; //導入方法依賴的package包/類
public void populateTypeComboBox(JComboBox comboBox) {

		ArrayList<VariationFunctionContext> typeList;

		typeList = this.variationFunctionContextList;
		for (VariationFunctionContext context : typeList) {
			comboBox.addItem(context);
		}

		comboBox.setSelectedItem(this.defaultVariationFunctionContext);
	}
 
開發者ID:OpenDA-Association,項目名稱:OpenDA,代碼行數:12,代碼來源:VariationPerParameterTableController.java

示例13: init

import javax.swing.JComboBox; //導入方法依賴的package包/類
@Override
public void init(Component parent)
{
	JLabel text = new JLabel(CurrentLocale.get("security.editor.itemstatus")); //$NON-NLS-1$

	statuses = new JComboBox();

	for( ItemStatus status : ItemStatus.values() )
	{
		statuses.addItem(status);
	}

	statuses.addActionListener(new ActionListener()
	{
		@Override
		public void actionPerformed(ActionEvent e)
		{
			saveCurrentSelection();
			loadCurrentSelection();
		}
	});

	editor = new AccessEditor(clientService.getService(RemoteTLEAclManager.class),
		clientService.getService(RemoteUserService.class));

	final int height1 = statuses.getPreferredSize().height;
	final int width1 = text.getPreferredSize().width;

	final int[] rows = {height1, TableLayout.FILL,};
	final int[] cols = {width1, TableLayout.DOUBLE_FILL, TableLayout.FILL,};

	setLayout(new TableLayout(rows, cols));
	add(text, new Rectangle(0, 0, 1, 1));
	add(statuses, new Rectangle(1, 0, 1, 1));
	add(editor, new Rectangle(0, 1, 3, 1));
}
 
開發者ID:equella,項目名稱:Equella,代碼行數:37,代碼來源:ItemStatusAccessControlTab.java

示例14: createReplacementPanel

import javax.swing.JComboBox; //導入方法依賴的package包/類
protected void createReplacementPanel(JPanel panel) {
    panel.add(getReplacemetPanel(), java.awt.BorderLayout.CENTER);
    JPanel aligmentPanel = new JPanel(new FlowLayout(FlowLayout.LEFT));
    aligmentPanel.add(new JLabel(ResourceLoader.getString("Aligment")));
    aligments = new JComboBox();
    aligments.addItem(ResourceLoader.getString("Aligment.Left"));
    aligments.addItem(ResourceLoader.getString("Aligment.Center"));
    aligments.addItem(ResourceLoader.getString("Aligment.Right"));
    aligmentPanel.add(aligments);
    this.add(aligmentPanel, java.awt.BorderLayout.CENTER);
}
 
開發者ID:Vitaliy-Yakovchuk,項目名稱:ramus,代碼行數:12,代碼來源:SectorNameEditor.java

示例15: createTop

import javax.swing.JComboBox; //導入方法依賴的package包/類
private JComponent createTop()
{
	JPanel panel1 = new JPanel(new FlowLayout(FlowLayout.LEFT, 0, 0));
	mappingBox = new JComboBox();
	mappingBox.addItem(new IMSMapping(schema));
	mappingBox.addItem(new HTMLMapping(schema));
	mappingBox.addItem(new ScriptedLiteralMapping(schema));
	mappingBox.addItemListener(this);
	panel1.add(mappingBox);
	return panel1;
}
 
開發者ID:equella,項目名稱:Equella,代碼行數:12,代碼來源:MapperTab.java


注:本文中的javax.swing.JComboBox.addItem方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。