Hi Programmers! This is my code, i have been having issues with it. It should change the ComboBox "MethodType" to have new items. I used to have it all in if statements however it was then running all of the code instead of just the needed part. A case statement will jump out once the code has been run. it better code.
when i put a number in the text field "Bells"
Help please!
public void actionPerformed(ActionEvent e) {
if(e.getSource() == Bells) {
switch (Bells.getText()){
case "4":
MethodType.setModel(new DefaultComboBoxModel(new String[] {"Minimus","Other"}));//causes a problem 2
MethodType.setSelectedItem(SelectedItem);
BellsError.setVisible(false);
break;
case "6":
System.out.println("done");
MethodType.setModel(new DefaultComboBoxModel(new String[] {"Doubles","Minor","Other"}));//causes a problem 2
MethodType.setSelectedItem(SelectedItem);
BellsError.setVisible(false);
System.out.println("end");
break;
case "8":
MethodType.setModel(new DefaultComboBoxModel(new String[] {"Triples","Major","Other"}));//causes a problem 2
MethodType.setSelectedItem(SelectedItem);
BellsError.setVisible(false);
break;
case "10":
MethodType.setModel(new DefaultComboBoxModel(new String[] {"Caters","Royal","Other"}));//causes a problem 2
MethodType.setSelectedItem(SelectedItem);
BellsError.setVisible(false);
break;
case "12":
MethodType.setModel(new DefaultComboBoxModel(new String[] {"Sinques","Maximus","Other"}));//causes a problem 2
MethodType.setSelectedItem(SelectedItem);
BellsError.setVisible(false);
break;
default:
BellsError.setVisible(true);
MethodType.setModel(new DefaultComboBoxModel(new String[] {"Minimus","Doubles","Minor","Triples","Major","Ca ters","Royal","Sinques","Maximus","Other"}));
break;
}
}