String[] boxData = {"Index0", "Index1", "Index2"};
ComboBox box = new ComboBox(boxData);
ActionListener actionListener = new ActionListener()
{
public void actionPerformed(ActionEvent evt)
{
if(box.getSelectedIndex() == 0) // "Index0" ist gewählt
{
//tu dies und das
}
if(box.getSelectedIndex() == 1) // "Index1" ist gewählt
{
//tu etwas sinnvolles
}
}
}
box.addActionListener(actionListener);