How do I populate a JComboBox with an ArrayList?
问题 I need to populate a JComboBox with an ArrayList. Is there any way to do this? 回答1: Use the toArray() method of the ArrayList class and pass it into the constructor of the JComboBox See the JavaDoc and tutorial for more info. 回答2: Elegant way to fill combo box with an array list : List<String> ls = new ArrayList<String>(); jComboBox.setModel(new DefaultComboBoxModel(ls.toArray())); 回答3: I don't like the accepted answer or @fivetwentysix's comment regarding how to solve this. It gets at one