Search code examples
javaswingenumsjcombobox

Populating Swing JComboBox from Enum


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!


Solution

  • try:

    new JComboBox(Mood.values());