Hello again all,
I'm still trying to work out my JComboBox and I'm having trouble with my ActionListener. I would like to have some JLabels change when I make a selection in my box.
Code:public void admitPane(){ JLabel labelAdmit = new JLabel ("Admit"); JPanel admitCard = new JPanel(); JLabel label1=new JLabel(); JLabel label2=new JLabel(); JLabel label3=new JLabel(); admitCard.add (labelAdmit); deck.add (admitCard, "Admit"); JComboBox studentBox = new JComboBox(nameArray); admitCard.add (studentBox); studentBox.addActionListener(this); JRadioButton a1 = new JRadioButton ("accept", false); JRadioButton r1 = new JRadioButton ("reject", true); JRadioButton a2 = new JRadioButton ("accept", false); JRadioButton r2 = new JRadioButton ("reject", true); JRadioButton a3 = new JRadioButton ("accept", false); JRadioButton r3 = new JRadioButton ("reject", true); ... if (event.getSource() == studentBox) { studentIndex =studentBox.getSelectedIndex(); school1 =arrayOfStudents[studentIndex].getUniversity(0); school2 =arrayOfStudents[studentIndex].getUniversity(1); school3 =arrayOfStudents[studentIndex].getUniversity(2); label1.setText (school1); label2.setText(school2); label3.setText (school3); school1 =arrayOfStudents[studentIndex].getUniversity(0); school2 =arrayOfStudents[studentIndex].getUniversity(1); school3 =arrayOfStudents[studentIndex].getUniversity(2); label1.setText (school1); label2.setText(school2); label3.setText (school3);


Reply With Quote


Bookmarks