Java JComboBox is it possible to set editable true into one item only?
问题 i want to create a JComboBox that have a three items on it.. I want to set editable only to the last item of the JComboBox for example: JComboBox cb = new JComboBox(); cb.addItem("Dog"); cb.addItem("Cat"); cb.addItem("Other"); when i drop down the JComboBox and choose the item Others.. JComboBox became editable.. how can I do that? 回答1: You can use an ItemListener to know which item is selected and then you can set the JComboBox editable as needed. Try this example: import java.awt.Dimension;