I am currently modelling a booking system for a cinema. Have been tasked with loading data from a text file and displaying it in certain text fields and combo boxes. I can load the WHOLE file into A text field but don't know how to split it up and add to others.
TEXT FILE INPUT - (type of booking - show / title / start time (hour)/(minute) / duration)
(type of booking - booking / name / title / (hour) / (minute) / seats booked)
S, Tenet, 19, 30, 150
S, No Time to Die, 18, 00, 163
S, No Time to Die, 21, 00, 163
S, Skyfall, 20, 00, 162
B, Adam, Skyfall, 20, 00, G4, G5, G8, G3, G7, G6, G1, G2
B, Chris, A Christmas Carol, 17, 15, H7, H8
B, David, No Time to Die, 21, 00, F4, F3, F5, F6
Currently my seats are buttons labelled in the GUI accordingly. They are required to appear 'clicked' if they are booked.
Code for my 'open' file button.
private void OpenMenuItemActionPerformed(java.awt.event.ActionEvent evt) {
int returnVal = FileChooser.showOpenDialog(this);
if (returnVal == JFileChooser.APPROVE_OPTION) {
File file = FileChooser.getSelectedFile();
try {
// What to do with the file,
//Somewhere to go -> .read(new FileReader( file.getAbsolutePath() ), null );
} catch (IOException ex) {
System.out.println("problem accessing file"+file.getAbsolutePath());
}
} else {
System.out.println("File access cancelled by user.");
}
}