So my assignment says to create a sequential file. My professor gave me this simple code for the actionperformed:
public void actionPerformed( ActionEvent e
I found the solution, it was right in front of my eyes, here it is for future users.
public void actionPerformed(ActionEvent e){
//FOR STATE AND COUNTRY
String country = (String)comboBox_1.getSelectedItem();
Object o = states.get(country);
if (o == null){
comboBox_2.setModel(new DefaultComboBoxModel());
}
else{
comboBox_2.setModel(new DefaultComboBoxModel((String[])o));
}
//****DONE WITH THE STATE AND COUNTRY COMBOBOXES*****
// this was the solution for my problem
if(e.getSource==buttonToAddRecords){
addRecord( ) ;
}
if(e.getSource( ) == btnDone){
try{
output.close( );
}
catch(IOException io){
System.err.println("File not closed properly\n" +
e.toString( ));
System.exit(1);
}
System.exit(0);
}
}