Creating a read-only and editable JComboBox Component
import javax.swing.JComboBox;
public class Main {
public static void main(String[] argv) throws Exception {
// Create a read-only combobox
String[] items = { "item1", "item2" };
JComboBox readOnlyCB = new JComboBox(items);
// Create an editable combobox
items = new String[] { "item1", "item2" };
JComboBox editableCB = new JComboBox(items);
editableCB.setEditable(true);
}
}
Related examples in the same category