I have tried to use the suggested methods but unable to determine how I can use action listeners within an action listener as suggested...
I want to change the value of first combo box and want the next combo box to be updated automatically upon change, similarly text box is changed when combobox_1 is changed...
String[] b = a.getCourseCodes();
final List f = new ArrayList();
final JComboBox comboBox = new JComboBox(b);
comboBox.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent arg0) {
String item = comboBox.getSelectedItem().toString();
}
});
comboBox.setEditable(true);
comboBox.setBounds(360, 70, 86, 20);
contentPane.add(comboBox);
JLabel lblStudentName = new JLabel("Student Name");
lblStudentName.setBounds(270, 149, 80, 14);
contentPane.add(lblStudentName);
String[] v = a.getStudentID(comboBox.getSelectedItem().toString());
final JComboBox comboBox_1 = new JComboBox(v);
comboBox_1.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent arg0) {
String item = comboBox_1.getSelectedItem().toString();
}
});
comboBox_1.setBounds(360, 108, 86, 20);
contentPane.add(comboBox_1);
textField_3 = new JTextField();
String y = a.getStudentName(comboBox_1.getSelectedItem().toString());
textField_3.setText(y);
textField_3.setEditable(false);
textField_3.setBounds(360, 146, 86, 20);
contentPane.add(textField_3);
textField_3.setColumns(10);
Kindly help by editing the code so can have a clear idea... Thanks