Reputation: 3
Is it possible to add a String
to a JComboBox
without using an array? I have an adding button that should add to combo box after clicking on it but I don't know how to do that.
Upvotes: 0
Views: 70
Reputation: 41208
Andrew is correct, you don't need to go to the model though. The jComboBox
class provides an addItem method for you.
Upvotes: 1
Reputation: 168845
Use DefaultComboBoxModel.addElement(E)
. More generally, see How to Use Combo Boxes.
Upvotes: 2