本文整理汇总了Java中javax.swing.JComboBox.setEditable方法的典型用法代码示例。如果您正苦于以下问题:Java JComboBox.setEditable方法的具体用法?Java JComboBox.setEditable怎么用?Java JComboBox.setEditable使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javax.swing.JComboBox
的用法示例。
在下文中一共展示了JComboBox.setEditable方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: addChoice
import javax.swing.JComboBox; //导入方法依赖的package包/类
/** Create a choice menu.
* @param name The name used to identify the entry (when calling get).
* @param label The label to attach to the entry.
* @param values The list of possible choices.
* @param defaultChoice Default choice.
* @param editable True if an arbitrary choice can be entered, in addition
* to the choices in values.
* @param background The background color for the editable part.
*/
public void addChoice(
String name,
String label,
String[] values,
String defaultChoice,
boolean editable,
Color background) {
JLabel lbl = new JLabel(label + ": ");
lbl.setBackground(_background);
JComboBox combobox = new JComboBox(values);
combobox.setEditable(editable);
// FIXME: Typical of Swing, the following does not set
// the background color. How does one set the background
// color?
combobox.setBackground(background);
combobox.setSelectedItem(defaultChoice);
_addPair(name, lbl, combobox, combobox);
// Add the listener last so that there is no notification
// of the first value.
combobox.addItemListener(new QueryItemListener(name));
}
示例2: addAndGetKeyForGlobalData
import javax.swing.JComboBox; //导入方法依赖的package包/类
private Object[] addAndGetKeyForGlobalData(GlobalDataModel gdModel) {
Object[] objects = new Object[2];
JComboBox jcb = new JComboBox(gdModel.getKeys().toArray());
jcb.setEditable(true);
JOptionPane.showMessageDialog(null, jcb, "Select or Enter a GlobalId", JOptionPane.QUESTION_MESSAGE);
String key = Objects.toString(jcb.getSelectedItem(), "");
if (key.trim().isEmpty()) {
key = "#gd1";
} else if (!key.startsWith("#")) {
key = "#" + key;
}
objects[0] = key;
if (gdModel.getRowCount() == 0
|| !gdModel.getKeys().contains(key)) {
gdModel.addRecord();
gdModel.setValueAt(key, gdModel.getRowCount() - 1, 0);
objects[1] = gdModel.getRowCount() - 1;
} else if (gdModel.getKeys().contains(key)) {
objects[1] = gdModel.getRecordIndexByKey(key);
}
return objects;
}
示例3: confirm
import javax.swing.JComboBox; //导入方法依赖的package包/类
public void confirm(EventObject fe) {
JTextField tf = (JTextField) fe.getSource();
JComboBox combo = (JComboBox) tf.getParent();
if (combo==null)
return;
if (fe instanceof FocusEvent) {
combo.getEditor().getEditorComponent().removeFocusListener(this);
} else {
combo.getEditor().getEditorComponent().removeKeyListener(this);
}
Configuration config = lastSelected;
config.setDisplayName(tf.getText());
combo.setSelectedItem(config);
combo.setEditable(false);
currentActiveItem = null;
}
示例4: InputDataPanel
import javax.swing.JComboBox; //导入方法依赖的package包/类
public InputDataPanel(List<String> previouslyUsedURLs) {
setSize(new Dimension(900, 300));
setPreferredSize(new Dimension(900, 300));
setMinimumSize(new Dimension(450, 300));
setLayout(null);
JLabel lblInputDataUrl = new JLabel("Input data URL");
lblInputDataUrl.setBounds(12, 12, 105, 15);
add(lblInputDataUrl);
lblUrlIsInvalid = new JLabel("URL is invalid!");
lblUrlIsInvalid.setVisible(false);
lblUrlIsInvalid.setBounds(12, 70, 105, 15);
add(lblUrlIsInvalid);
btnValidate = new JButton("Validate");
btnValidate.setBounds(335, 34, 93, 25);
//add(btnValidate);
comboBox = new JComboBox();
comboBox.setEditable(true);
comboBox.setBounds(12, 34, 311, 24);
comboBox.setModel(new URLComboBoxModel(previouslyUsedURLs));
add(comboBox);
}
示例5: confirm
import javax.swing.JComboBox; //导入方法依赖的package包/类
private void confirm(EventObject fe) {
JTextField tf = (JTextField) fe.getSource();
JComboBox combo = (JComboBox) tf.getParent();
if (combo==null)
return;
if (fe instanceof FocusEvent) {
combo.getEditor().getEditorComponent().removeFocusListener(this);
} else {
combo.getEditor().getEditorComponent().removeKeyListener(this);
}
Configuration config = configName==null ?
ConfigurationsManager.getDefault().duplicate(lastSelected, tf.getText(), tf.getText()):
ConfigurationsManager.getDefault().create(tf.getText(), tf.getText());
combo.setSelectedItem(config);
combo.setEditable(false);
}
示例6: createAndShowGUI
import javax.swing.JComboBox; //导入方法依赖的package包/类
private static void createAndShowGUI() {
frame = new JFrame();
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setSize(200, 200);
frame.setLocation(100, 100);
table = new JTable(
new String[][]{{TEST1}}, new String[]{"Header"});
JComboBox<String> comboBox = new JComboBox<>();
comboBox.setEditable(true);
table.getColumnModel().getColumn(0).setCellEditor(
new DefaultCellEditor(comboBox));
frame.getContentPane().add(table);
frame.setVisible(true);
}
示例7: getCellEditor
import javax.swing.JComboBox; //导入方法依赖的package包/类
@Override
public TableCellEditor getCellEditor(int row, int column) {
JComboBox typeBox = new JComboBox(Attributes.KNOWN_ATTRIBUTE_TYPES);
typeBox.setEditable(true);
typeBox.setBackground(javax.swing.UIManager.getColor("Table.cellBackground"));
return new DefaultCellEditor(typeBox);
}
开发者ID:transwarpio,项目名称:rapidminer,代码行数:8,代码来源:ExampleSourceConfigurationWizardAttributeTypeTable.java
示例8: actionPerformed
import javax.swing.JComboBox; //导入方法依赖的package包/类
@Override
public void actionPerformed(ActionEvent ae) {
currentActiveItem = this;
JComboBox combo = (JComboBox) ae.getSource();
combo.setEditable(true);
combo.getEditor().getEditorComponent().addFocusListener(this);
combo.getEditor().getEditorComponent().addKeyListener(this);
combo.addPopupMenuListener(this);
combo.setSelectedItem(configName == null ? lastSelected + "1" : configName);
}
示例9: AccountTransferDialog
import javax.swing.JComboBox; //导入方法依赖的package包/类
/**
* Set up and show the dialog. The first Component argument determines which
* frame the dialog depends on; it should be a component in the dialog's
* controlling frame. The second Component argument should be null if you
* want the dialog to come up with its left corner in the center of the
* screen; otherwise, it should be the component on top of which the dialog
* should appear.
*/
public AccountTransferDialog(Component frameComp, Component locationComp,
String title, Object[] brokers,I_TickerManager tickerManager) {
super(frameComp, locationComp, title, tickerManager);
brokerList = new JComboBox(brokers);
brokerList.setEditable(true);
brokerList.setSelectedIndex(0);
newBrokerField = new JTextField(FIELD_LEN);
newBrokerField.setEditable(true);
newBrokerField.setText("");
newBrokerField.addKeyListener(this);
dateFieldLabel = new JLabel("Siirtopäivä: ");
dateFieldLabel.setLabelFor(dateChooser);
brokerFieldLabel = new JLabel("Vanha välittäjä: ");
brokerFieldLabel.setLabelFor(brokerList);
newBrokerFieldLabel = new JLabel("Uusi välittäjä: ");
newBrokerFieldLabel.setLabelFor(newBrokerField);
init(getDialogLabels(), getDialogComponents());
}
示例10: setupGui
import javax.swing.JComboBox; //导入方法依赖的package包/类
private void setupGui()
{
JLabel typeLabel = new JLabel(CurrentLocale.get("com.tle.admin.schema.manager.transformdialog.name")); //$NON-NLS-1$
JLabel fileLabel = new JLabel(CurrentLocale.get("com.tle.admin.schema.manager.transformdialog.xsl")); //$NON-NLS-1$
schemaType = new JComboBox();
schemaType.setEditable(true);
fileSelector = new FileSelector(CurrentLocale.get("com.tle.admin.schema.manager.transformdialog.browse")); //$NON-NLS-1$
fileSelector.setFileFilter(FileFilterAdapter.XSLT());
ok = new JButton(CurrentLocale.get("com.tle.admin.ok")); //$NON-NLS-1$
JButton cancel = new JButton(CurrentLocale.get("com.tle.admin.cancel")); //$NON-NLS-1$
ok.addActionListener(this);
cancel.addActionListener(this);
final int height1 = typeLabel.getPreferredSize().height;
final int height2 = schemaType.getPreferredSize().height;
final int height3 = fileSelector.getPreferredSize().height;
final int height4 = ok.getPreferredSize().height;
final int width1 = cancel.getPreferredSize().width;
final int[] rows = {height1, height2, height1, height3, height4,};
final int[] cols = {TableLayout.FILL, width1, width1,};
all = new JPanel(new TableLayout(rows, cols));
all.setBorder(BorderFactory.createEmptyBorder(5, 5, 5, 5));
all.add(typeLabel, new Rectangle(0, 0, 3, 1));
all.add(schemaType, new Rectangle(0, 1, 3, 1));
all.add(fileLabel, new Rectangle(0, 2, 3, 1));
all.add(fileSelector, new Rectangle(0, 3, 3, 1));
all.add(ok, new Rectangle(1, 4, 1, 1));
all.add(cancel, new Rectangle(2, 4, 1, 1));
}
示例11: DataComboBoxSupport
import javax.swing.JComboBox; //导入方法依赖的package包/类
/** Not private because used in tests. */
DataComboBoxSupport(JComboBox comboBox, DataComboBoxModel dataModel, boolean allowAdding) {
this.dataModel = dataModel;
this.allowAdding = allowAdding;
comboBox.setEditable(false);
comboBox.setModel(new ItemComboBoxModel());
comboBox.setRenderer(new ItemListCellRenderer());
comboBox.addActionListener(new ItemActionListener());
comboBox.addPopupMenuListener(new ItemPopupMenuListener());
}
示例12: initAntTargetEditor
import javax.swing.JComboBox; //导入方法依赖的package包/类
private void initAntTargetEditor(List<String> targets) {
JComboBox combo = new JComboBox();
combo.setEditable(true);
for (String target : targets) {
combo.addItem(target);
}
customTargets.setDefaultEditor(JComboBox.class, new DefaultCellEditor(combo));
}
示例13: setEmptyModel
import javax.swing.JComboBox; //导入方法依赖的package包/类
private void setEmptyModel(JComboBox combo) {
if (combo != null) {
combo.setModel(WizardUtils.createComboEmptyModel());
combo.setEnabled(false);
combo.setEditable(false);
checkValidity();
}
}
示例14: CapitalRepaymentDialog
import javax.swing.JComboBox; //导入方法依赖的package包/类
/**
* Set up and show the dialog. The first Component argument determines which
* frame the dialog depends on; it should be a component in the dialog's
* controlling frame. The second Component argument should be null if you
* want the dialog to come up with its left corner in the center of the
* screen; otherwise, it should be the component on top of which the dialog
* should appear.
*/
public CapitalRepaymentDialog(Component frameComp, Component locationComp,
String title, Object[] brokers, Object[] sectors,
Map<String, List<String>> stocks, I_TickerManager tickerManager) {
super(frameComp, locationComp, title, tickerManager);
this.stocks = stocks;
// Brokers
brokerList = new JComboBox(brokers);
brokerList.setEditable(true);
// Sectors
sectorList = new JComboBox(sectors);
sectorList.setActionCommand(SECTOR_CHANGED);
sectorList.addActionListener(this);
// Stocks
stocksList = new JComboBox();
updateStockList((String) sectorList.getSelectedItem());
stocksList.setActionCommand(STOCK_SELECTED);
stocksList.addActionListener(this);
amountField.addKeyListener(this);
costField.addKeyListener(this);
totalCostField.setEditable(false);
totalCostField.setText("0.00");
sectorFieldLabel = new JLabel("Toimiala: ");
sectorFieldLabel.setLabelFor(sectorList);
stockFieldLabel = new JLabel("Arvopaperi: ");
stockFieldLabel.setLabelFor(stocksList);
dateFieldLabel = new JLabel("Maksupäivä: ");
dateFieldLabel.setLabelFor(dateChooser);
amountFieldLabel = new JLabel("Määrä: ");
amountFieldLabel.setLabelFor(amountField);
costFieldLabel = new JLabel("Palautus/osake: ");
costFieldLabel.setLabelFor(costField);
brokerFieldLabel = new JLabel("Välittäjä: ");
brokerFieldLabel.setLabelFor(brokerList);
totalCostFieldLabel = new JLabel("yhteensä: ");
totalCostFieldLabel.setLabelFor(totalCostField);
String stockName = (String) stocksList.getSelectedItem();
updateRateField(stockName);
init(getDialogLabels(), getDialogComponents());
}
示例15: ClassTable
import javax.swing.JComboBox; //导入方法依赖的package包/类
ClassTable() {
super(new ClassTableModel());
disabledCellRenderer = new DisabledCellRenderer();
//BEGIN Federico Dall'Orso 8/3/2005
//NEW
classTypeComboBoxCell = new ComboBoxCell(CLASS_TYPENAMES);
deleteButton = new JButton(deleteOneClass);
deleteButtonCellRenderer = new ButtonCellEditor(deleteButton);
enableDeletes();
rowHeader.setRowHeight(18);
setRowHeight(18);
//END Federico Dall'Orso 8/3/2005
JComboBox classTypeBox = new JComboBox(CLASS_TYPENAMES);
classTypeCellEditor = new DefaultCellEditor(classTypeBox);
classTypeBox.setEditable(false);
setColumnSelectionAllowed(false);
setRowSelectionAllowed(true);
// not beautiful, but effective. See ClassTableModel.getColumnClass()
setDefaultRenderer(DisabledCellRenderer.class, disabledCellRenderer);
setDefaultEditor(String.class, classTypeCellEditor);
setDisplaysScrollLabels(true);
installKeyboardAction(getInputMap(), getActionMap(), deleteClass);
mouseHandler = new ExactTable.MouseHandler(makeMouseMenu());
mouseHandler.install();
help.addHelp(this,
"Click or drag to select classes; to edit data single-click and start typing. Right-click for a list of available operations");
help.addHelp(moreRowsLabel, "There are more classes: scroll down to see them");
help.addHelp(selectAllButton, "Click to select all classes");
tableHeader.setToolTipText(null);
rowHeader.setToolTipText(null);
help.addHelp(rowHeader, "Click, SHIFT-click or drag to select classes");
}