Creating a JComboBox Component

// Create a read-only combobox String[] items = {"item1", "item2"}; JComboBox readOnlyCB = new JComboBox(items);
By default, a combobox only allows the user to select from a predefined list of values. The combobox can be made editable which not only allows the user to select from the predefined list but also to type in any string.
// Create an editable combobox items = new String[]{"item1", "item2"}; JComboBox editableCB = new JComboBox(items); editableCB.setEditable(true);

Post a comment

More information about formatting options

CAPTCHA
This question is for testing whether you are a human visitor and to prevent automated spam submissions.
Image CAPTCHA
Enter the characters shown in the image. Ignore spaces and be careful about upper and lower case.