import javax.swing.JComboBox;
import javax.swing.JFrame;
public class Main {
public static void main(String argv[]) throws Exception {
JComboBox comboBox = new JComboBox(new Item[] {
new Item("Major", "red"), new Item("Critical", "dark"),
new Item("Minor", "green") });
comboBox.addActionListener(e -> {
JComboBox combo = (JComboBox) e.getSource();
Item item = (Item) combo.getSelectedItem();
System.out.println(item.getColor());
});
JFrame frame = new JFrame();
frame.add(comboBox);
frame.pack();
frame.setVisible(true);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
}
}
class Item {
private String name;
private String color;
public Item(String name,