0

I am trying to update a list in with the Swing Component, JComboBox. How do I add an entire list w/o re-allocating memory to a new JComboBox or w/o iterating through a list and adding an item line by line?

Tim Nuwin
  • 2,775
  • 2
  • 29
  • 63
  • You will need to create your own `ComboBoxModel` ... the [`DefaultComboBoxModel`](https://docs.oracle.com/javase/7/docs/api/javax/swing/DefaultComboBoxModel.html) does not support that. – AJNeufeld Sep 20 '17 at 13:45

1 Answers1

0

Have you tried this one:

List list = new ArrayList();

JComboBox box = new JComboBox(list.toArray()); 

The following links could be helpful:

How to update JComboBox content from ArrayList?

How do I populate a JComboBox with an ArrayList?

Naveed Kamran
  • 453
  • 1
  • 4
  • 16