Populating Swing JComboBox from Enum

try:

new JComboBox(Mood.values());

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.


If you don't want to (or can't) change initialization with default constructor, then you can use setModel() method:

JComboBox<Mood> comboBox = new JComboBox<>();
comboBox.setModel(new DefaultComboBoxModel<>(Mood.values()));