Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Changing the Contents of the JComboBox

I would like to change the contents of the list of a JComboBox (like adding another list in place of and older one). Is there any way I might be able to do that? Thanks in advance!

like image 909
acostache Avatar asked Dec 29 '08 00:12

acostache


1 Answers

If you want to be able to add and remove items from an existing combo box at runtime, the underlying data model for the combo box needs to be a MutableComboBoxModel

Google for that class for interface information and for examples of how to use it.

Note that if you want the user to type in new values, you also need to make the box editable.

You can find some links to examples here.

like image 159
Uri Avatar answered Oct 21 '22 00:10

Uri