Reputation: 22156
I have a combo box whose values need to correspond to the values of an enumeration that I've defined.
How can I set up the combo box in the NetBeans GUI so that it takes the values directly from the enumeration?
Upvotes: 0
Views: 1690
Reputation: 22156
Based on an answer from this thread, I have found the solution to be
Properties
...
' next to modelCustom code
for 'Set yourComboBox
's model
property using:'new DefaultComboBoxModel(YourEnum.values())
into the given text field.DefaultComboBoxModel
and YourEnum
are imported.Unfortunately, this doesn't seem to show the values of the combo box in the 'Preview Design' view, but it does show the values if you embed your component into another component (e.g. if you defined your combo box as a part of a panel and you later add that panel to another panel).
Upvotes: 2