The name is misleading. JComboBox does not let you select combinations of options, the way you can with a JList, just a single option. The combo-moniker comes from the fact it has a combination write in field and select from pre-existing choices.
To control how the new write-in field possibility is keyed, you can write a custom ComboBoxEditor based on BasicComboBoxEditor.
JComboBox uses setSelectedItem instead of select. getSelectedItem returns an Object you must cast to a String. The use of Objects for your choices allows more flexibility in rendering the choices.
Here is how to let the user select an enum in a GUI (Graphic User Interface) using JComboBox.
Here is how to use a JComboBox with simple Strings as the possible choices.
This page is posted |
http://mindprod.com/jgloss/jcombobox.html | |
Optional Replicator mirror
|
J:\mindprod\jgloss\jcombobox.html | |
Please read the feedback from other visitors,
or send your own feedback about the site. Contact Roedy. Please feel free to link to this page without explicit permission. | ||
Canadian
Mind
Products
IP:[65.110.21.43] Your face IP:[18.224.63.123] |
| |
Feedback |
You are visitor number | |