1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48
| Action action = new Action();
Moving moving = new Moving();
JComboBox comboBox = new JComboBox();
comboBox.addItem("A");
comboBox.addItem("B");
comboBox.addItem("C");
comboBox.addItem("D");
comboBox.addItem("E");
comboBox.addItem("F");
this.getContentPane().add(comboBox);
this.getContentPane().add(action);
this.getContentPane().add(moving);
moving.setBounds(0,0,657,330);
action.setBounds(25,10,800,800);
comboBox.setBounds (400,60,60,40);
comboBox.setEditable(false);
comboBox.setSelectedIndex (1);
// comboBox.setFocusable(true);
ActionListener actionListener = new ActionListener() {
public void actionPerformed(ActionEvent actionEvent) {
System.out.println("Selected: " + comboBox.getSelectedItem());
if (comboBox.getSelectedItem() == "B") {
System.out.println("Delete key hit");
ConfigManager1.getInstance1().cycleConfigs();
}
if (comboBox.getSelectedItem() == "C") {
System.out.println("Delete key hit");
ConfigManager1.getInstance1().cycleConfigs();
}
if (comboBox.getSelectedItem() == "D") {
System.out.println("Delete key hit");
ConfigManager1.getInstance1().cycleConfigs();
}
if (comboBox.getSelectedItem() == ".") {
System.out.println("Delete key hit");
ConfigManager1.getInstance1().cycleConfigs();
}
}
}; |