Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Adding an array to a combo box

I want to add an array to an existing combobox without passing the array object as a argument in the constructor. Is there perhaps a way to do this by using a method?

Something like the following

Object[] comboBoxDisplay = myAnimals.toArray();
    comboAnimals.add(comboBoxDisplay);
like image 726
Arianule Avatar asked Aug 08 '26 09:08

Arianule


1 Answers

Use a DefaultComboBoxModel to construct the JComboBox it provides an addElement() method.

You'd have to call that from a loop, rather than as a single statement, but then, that's why they pay us 'the big bucks'. ;)

like image 185
Andrew Thompson Avatar answered Aug 10 '26 01:08

Andrew Thompson



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!