How do I populate a JComboBox with an ArrayList?

Abdul Khaliq picture Abdul Khaliq · Aug 18, 2009 · Viewed 130.1k times · Source

I need to populate a JComboBox with an ArrayList. Is there any way to do this?

Answer

eric.christensen picture eric.christensen · Aug 18, 2009

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.