I would like to populate a java.swing JComboBox with values from an Enum.
e.g.
public enum Mood { HAPPY, SAD, AWESOME; }
and have these three values populate a readonly JComboBox.
Thanks!
I would like to populate a java.swing JComboBox with values from an Enum.
e.g.
public enum Mood { HAPPY, SAD, AWESOME; }
and have these three values populate a readonly JComboBox.
Thanks!
The solution proposed by @Pierre is good. Usually you use a DefaultComboBoxModel or a ComboBoxModel or bindings to the ComboBoxModel for more complex stuff.
By default a JComboBox is not editable.