Can someone please help me understand why two sets of JButtons works here, but the one I'm trying to add doesn't?
The code is part of an application that adds/edits a list of names and some information connected to those names. I'm trying to add a delete function.
The program is set up to display one of four
cards. The first card gives you the option of adding, editing, or deleting a student. The second card displays if you select the edit option. It displays a JComboBox that shows the list of names for editing. The submit and cancel buttons work on this card. The third card displays a text box which allows you to add a name to the list. The submit and cancel buttons work here, as well. The fourth card is the one I'm trying to add, and even though I've followed the same logic as for the two
cards that work, this fourth card won't even display. When the Edit Student button is selected, I get a series of error messages that seem to indicate that the event can't be traced back to its source.
JPanel card1 = new JPanel();
JPanel buttonPanel = new JPanel();
buttonPanel.setLayout( new GridLayout( 6 , 1 ) );
newStudent = new JButton( "Add New Student" );
editStudent = new JButton( "Edit existing Student" );
deleteStudent = new JButton( "Delete existing Student" );
finish = new JButton( "Finish" );
htmlLog = new JButton( "Generate HTML Log" );
newStudent.addActionListener( firstActions );
editStudent.addActionListener( firstActions );
deleteStudent.addActionListener( firstActions );
finish.addActionListener( firstActions );
htmlLog.addActionListener( firstActions );
buttonPanel.add( newStudent );
buttonPanel.add( editStudent );
buttonPanel.add( deleteStudent );
buttonPanel.add( htmlLog );
buttonPanel.add( finish );
card1.add( buttonPanel );
card2 = new JPanel();
card3 = new JPanel();
card4 = new JPanel();
card2.setLayout( new FlowLayout( FlowLayout.CENTER , 20 , 10 ) );
card3.setLayout( new FlowLayout( FlowLayout.CENTER , 20 , 10 ) );
card4.setLayout( new FlowLayout( FlowLayout.CENTER , 20 , 10 ) );
card2.add( labelsAndFields1 );
card3.add( labelsAndFields2 );
card4.add( labelsAndFields3 );
buttons = new JPanel();
submit = new JButton( "Submit" );
cancel = new JButton( "Cancel" );
ButtonPanelActions buttonActions = new ButtonPanelActions();
submit.addActionListener( buttonActions );
submit.setActionCommand( "edit" );
cancel.addActionListener( buttonActions );
buttons.add( submit );
buttons.add( cancel );
card2.add( buttons );
buttons = new JPanel();
submit = new JButton( "Submit" );
cancel = new JButton( "Cancel" );
buttonActions = new ButtonPanelActions();
submit.addActionListener( buttonActions );
submit.setActionCommand( "add" );
cancel.addActionListener( buttonActions );
buttons.add( submit );
buttons.add( cancel );
card3.add( buttons );
buttons = new JPanel();
delete = new JButton( "Delete" );
cancel = new JButton( "Cancel" );
buttonActions = new ButtonPanelActions();
delete.addActionListener( buttonActions );
delete.setActionCommand( "delet" );
cancel.addActionListener( buttonActions );
buttons.add( delete );
buttons.add( cancel );
card4.add( buttons );
Obviously there's a lot of code that does other things, but can anyone see anything in here that would render card4 non-functional?
