本文整理汇总了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());
}
示例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++;
}
}
示例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;
}
示例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)");
}
示例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
}
}
}
示例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);
}
示例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;
}
示例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;
}
示例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);
}
示例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);
}
示例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);
}
};
}
示例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);
}
示例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));
}
示例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);
}
示例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;
}