The program is 90% done

...everything works except for one little thing...
THe date doesn't appear to be working

I tried messing around with the true false but it doesn't seem to have any affect....any one know the problem? Any help would be appreciated
[PHP]// Comsci Dossier
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import java.io.*;
import javax.swing.border.*;
import java.text.*;
public class AirBox extends JFrame {
private JComboBox destinationComboBox, mealComboBox, classComboBox, dayComboBox, displayComboBox, editComboBox, mealComboBox1, classComboBox1, flightComboBox;
// JTEXT AREAS
private JTextArea customerArea, searchResultArea, manifestArea;
// JTEXTFIELDS
private JTextField FirstNameField, LastNameField, mealField, flightField, deleteField, editField, searchField, searchField1, changeNameField;
// JLABELS
private JLabel FirstNameLabel, LastNameLabel, mealLabel, classLabel, customerLabel, MHSLabel, CMLabel, flightLabel, deleteLabel, editLabel, searchLabel, searchLabel1, businessNameJLabel;
//JBUTTONS
private JButton addButton, saveButton, loadButton, deleteButton, searchButton,
changeLastNameButton, newButton, ticketButton;
// SCROLLER
private JScrollPane customerListScrollPane;
//JRADIO BUTTONS
private JRadioButton inputRadio, editRadio, searchRadio;
// BUTTON GROUP
private ButtonGroup displayGroup;
//JPANELS
private JPanel editPanel, mainPanel, searchPanel;
// STRING for JCOMBOBOX
private String meal[] = { "Select Meal Type...", "Vegetarian","Meat" };
private String classS[] = { "Select Class...", "Business Class", "Second Class" };
private String editCh[] = { "Choose Data to edit...","Change First Name","Change Last Name","Change Meal Type"};
private String display[] = { "Manifest", "Seating Chart"};
private String destinations[] = { "Select Destination", "Mae Hong Son", "Chiang Mai"};
private String meals[] = { "Select Meal", "Normal", "Vegetarian" };
private String classes[] = { "Select Class", "Normal", "Business" };
private String day[] = { "Select Day...", "Monday", "Tuesday", "Wednesday",
"Thursday", "Friday" };
// INITIALIZE ObjectOutputStream and ObjectInputStream
private ObjectOutputStream recordfile;
private ObjectInputStream recordedfile;
// CREATE count and maximum size of array of objects
private String outputManifest, outputSeatingArray, outputTicket;
////////////////
private int count;
private int rowCount;
private int aisleCount;
private int businessClassRowCount;
private int businessClassAisleCount;
private int searchCounter;
final int size = 44; // 44 maximum passengers on a plane
//create string to display flight number
private String flightNum = "Flight ";
//create int records to keep track of total number of records entered
private int records;
/////////////////
/////////////////////
/////////////////////
///////////////////////
private JLabel BusinessClassJLabel; // JLabel that displays an image
//JPicture
private JLabel BusinessClass2JLabel; // JLabel that displays an image
// JLabel and JTextField for order number
private JLabel orderJLabel;
private JTextField orderJTextField;
// JLabel and JTextField for name
private JLabel nameJLabel;
private JTextField nameJTextField;
// JLabel and JTextField for addressline1
private JLabel addressLine1JLabel;
private JTextField addressLine1JTextField;
// JLabel and JTextField for addressLine2
private JLabel addressLine2JLabel;
private JTextField addressLine2JTextField;
//JLabel for product name
private JLabel productNameJLabel;
//JLabel for productQuantity
private JLabel productQuantityJLabel;
//JLabel for productPrice
private JLabel productPriceJLabel;
//JLabel for orderTotals
private JLabel orderTotalsJLabel;
// JCheckBox and JLabel for BusinessClass
private JCheckBox BusinessClassJCheckBox;
private JLabel BusinessClassPriceJLabel;
// JCheckBox and JLabel for EconomicClass
private JCheckBox EconomicClassJCheckBox;
private JLabel EconomicClassPriceJLabel;
//JTextField for BusinessClassquantity
private JTextField BusinessClassquantityJTextField;
//JTextField for EconomicClassquantity
private JTextField EconomicClassquantityJTextField;
//JTextField for BusinessClassprice
private JTextField BusinessClasspriceJTextField;
//JTextField for EconomicClassprice
private JTextField EconomicClasspriceJTextField;
//JTextField for BusinessClassTotals
private JTextField BusinessClassTotalsJTextField;
//JTextField for EconomicClassTotals
private JTextField EconomicClassTotalsJTextField;
// JLabel and JTextField for subtotal
private JLabel subtotalJLabel;
private JTextField subtotalJTextField;
// JLabel and JTextField for vat
private JLabel vatJLabel;
private JTextField vatJTextField;
// JLabel and JTextField for total
private JLabel totalJLabel;
private JTextField totalJTextField;
// JButton to initiate calculation
private JButton calculateJButton;
// Array of Objects
private PassengerData List[];
// Gui Setup
public AirBox()
{
super( "Airlines Reservation");
// create JTabbed Pane
JTabbedPane tabbedPane = new JTabbedPane();
records = 0;
rowCount = 1;
aisleCount = 0;
businessClassRowCount = 6;
businessClassAisleCount = 0;
List = new PassengerData[ size ];
count = -1;
// set up panel1 and add to JTabbedPane
JLabel label1 = new JLabel( "RESERVATION PANEL");
JPanel panel1 = new JPanel( null );
panel1.add( label1 );
tabbedPane.addTab( "RESERVATION FOR PASSENGER", null, panel1, "FirstPanel");
// Input a Meal Combobox for Meal Selection
mealComboBox = new JComboBox( meals );
panel1.add( mealComboBox );
mealComboBox.setBounds( 80, 80, 100, 20 );
mealComboBox.setSelectedIndex( 0 );
// Input A destination combobox for destination selection
destinationComboBox = new JComboBox( destinations );
panel1.add( destinationComboBox );
destinationComboBox.setBounds( 50, 150, 170, 20 );
destinationComboBox.setSelectedIndex( 0 );
// Input a Class comboBox for class selection
classComboBox = new JComboBox( classes );
panel1.add( classComboBox );
classComboBox.setBounds( 80, 110 , 100, 20 );
classComboBox.setSelectedIndex( 0 );
FirstNameLabel = new JLabel( "First Name:" );
panel1.add( FirstNameLabel );
FirstNameLabel.setBounds( 10, 20, 100, 20 );
FirstNameField = new JTextField();
panel1.add( FirstNameField );
FirstNameField.setBounds( 80, 20 , 100, 20);
LastNameLabel = new JLabel( "Last Name:" );
panel1.add( LastNameLabel );
LastNameLabel.setBounds( 10, 50, 100, 20 );
LastNameField = new JTextField();
panel1.add( LastNameField );
LastNameField.setBounds( 80, 50 , 100, 20);
mealLabel = new JLabel( "Meal Type:" );
panel1.add( mealLabel );
mealLabel.setBounds( 10, 80, 100, 20 );
classLabel = new JLabel( "Class:" );
panel1.add( classLabel );
classLabel.setBounds( 10, 110, 100, 20 );
flightLabel = new JLabel( "Flight:" );
panel1.add( flightLabel );
flightLabel.setBounds( 350, 20, 100, 20 );
flightField = new JTextField();
panel1.add( flightField );
flightField.setBounds( 400, 20 , 100, 20);
flightField.setEditable( false );
customerLabel = new JLabel( "Passengers" );
panel1.add( customerLabel );
customerLabel.setBounds( 250, 20, 100, 20 );
customerArea = new JTextArea();
panel1.add( customerArea );
customerArea.setEditable( false );
customerArea.setBounds( 250, 50, 300, 400 );
customerArea.setText( "# Name\t\tMeal\tClass\tSeat \n" );
customerListScrollPane = new JScrollPane( customerArea );
customerListScrollPane.setBounds( 250, 50, 400, 100 );
panel1.add( customerListScrollPane );
addButton = new JButton( "Add..." );
panel1.add( addButton );
addButton.setBounds( 50, 200, 100, 20 );
addButton.addActionListener( new ActionListener(){
public void actionPerformed( ActionEvent event ){
addCustomer();
}
}
);
saveButton = new JButton( "Save..." );
panel1.add( saveButton );
saveButton.setBounds( 50, 220, 100, 20 );
saveButton.addActionListener( new ActionListener(){
public void actionPerformed( ActionEvent event ){
OpenFile1();
SaveToFile(event);
}
}
);
newButton = new JButton( "New" );
panel1.add( newButton );
newButton.setBounds( 150, 220, 100, 20 );
newButton.addActionListener( new ActionListener(){
public void actionPerformed( ActionEvent event ){
if( count == -1 ){
destinationComboBox.setEnabled( true );
}
else{
ClearData();
count = -1;
records = 0;
aisleCount = 0;
rowCount = 1;
businessClassAisleCount = 0;
businessClassRowCount = 1;
}
}
}
);
dayComboBox = new JComboBox( day );
panel1.add( dayComboBox );
dayComboBox.setBounds( 50, 170, 170, 20 );
dayComboBox.setSelectedIndex( 0 );
dayComboBox.addItemListener( new ItemListener(){
public void itemStateChanged( ItemEvent event ){
FlightDayChanged( event );
}
}
);
/////////////////////////PANEL 1 OVER//////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////
JLabel label2 = new JLabel( "panel two", SwingConstants.CENTER );
JPanel panel2 = new JPanel( null );
panel2.add( label2 );
tabbedPane.addTab( "EDITING || DELETING || SEARCHING", null, panel2, "SecondPanel");
editLabel = new JLabel( "Choose record # to edit" );
panel2.add( editLabel );
editLabel.setBounds( 40, 15, 200, 20 );
editField = new JTextField();
panel2.add( editField );
editField.setBounds( 40, 40, 100, 20 );
deleteLabel = new JLabel( "Input Record Number to Delete" );
panel2.add( deleteLabel );
deleteLabel.setBounds( 40, 160, 200, 20 );
deleteButton = new JButton( "Delete Record" );
panel2.add( deleteButton );
deleteButton.setBounds( 30, 220, 200, 20 );
deleteButton.addActionListener( new ActionListener(){
public void actionPerformed( ActionEvent event ){
deleteRecord();
}
}
);
deleteField = new JTextField();
panel2.add( deleteField );
deleteField.setBounds( 40, 200, 100, 20 );
editPanel = new JPanel();
panel2.add( editPanel );
editPanel.setBounds( 20, 5, 215, 250 );
editPanel.setLayout( null );
editPanel.setBorder( new TitledBorder( "Edit" ) );
loadButton = new JButton( "Load..." );
panel1.add( loadButton );
loadButton.setBounds( 150, 200, 100, 20 );
loadButton.addActionListener( new ActionListener(){
public void actionPerformed( ActionEvent event ){
boolean opened = false;
opened = OpenFile();
if(opened)
{
LoadFromFile( event );
count--;
records = count + 1;
dataEditable();
}
}
}
);
inputRadio = new JRadioButton( "Input", true );
panel1.add( inputRadio );
inputRadio.setBounds( 10000, 455, 60, 20 );
inputRadio.addItemListener( new SelectedInputRadio() );
editRadio = new JRadioButton( "Edit", false );
panel2.add( editRadio );
editRadio.setBounds(0, 280, 50, 20 );
editRadio.addItemListener( new SelectedEditRadio() );
searchRadio = new JRadioButton( "Search", false );
panel2.add( searchRadio );
searchRadio.setBounds(0, 300, 80, 20 );
searchRadio.addItemListener( new SelectedSearchRadio() );
displayGroup = new ButtonGroup();
displayGroup.add( inputRadio );
displayGroup.add( searchRadio );
displayGroup.add( editRadio );
mealComboBox1 = new JComboBox( meal );
editPanel.add( mealComboBox1 );
mealComboBox1.setBounds( 10, 100, 100, 20 );
mealComboBox1.setSelectedIndex( 0 );
mealComboBox1.setVisible(false);
editComboBox = new JComboBox( editCh );
editPanel.add( editComboBox );
editComboBox.setBounds( 10, 70, 180, 20 );
editComboBox.setSelectedIndex( 0 );
editComboBox.addItemListener( new ItemListener(){
public void itemStateChanged( ItemEvent event ){
EditTypeChanged(event);
}
}
);
changeNameField = new JTextField();
editPanel.add( changeNameField );
changeNameField.setBounds( 10, 100, 100, 20 );
changeNameField.setEditable( false );
changeLastNameButton = new JButton("Edit File");
editPanel.add( changeLastNameButton );
changeLastNameButton.setBounds( 10, 130, 180, 20 );
changeLastNameButton.addActionListener( new ActionListener(){
public void actionPerformed( ActionEvent event ){
editData();
}
}
);
searchLabel = new JLabel( "First Name" );
panel2.add( searchLabel );
searchLabel.setBounds( 330, 70, 100, 20 );
searchLabel1 = new JLabel( "Last Name" );
panel2.add( searchLabel1 );
searchLabel1.setBounds( 330, 100, 100, 20 );
searchField = new JTextField();
panel2.add( searchField );
searchField.setBounds( 400, 70, 100, 20 );
searchField1 = new JTextField();
panel2.add( searchField1 );
searchField1.setBounds( 400, 100, 100, 20 );
searchButton = new JButton( "Search" );
panel2.add( searchButton );
searchButton.setBounds( 330, 40, 100, 20 );
searchButton.addActionListener( new ActionListener(){
public void actionPerformed( ActionEvent event ){
searchRecord();
ticketButton.setEnabled( true );
}
}
);
searchResultArea = new JTextArea();
panel2.add( searchResultArea );
searchResultArea.setEditable( false );
searchResultArea.setBounds( 315, 160, 190, 120 );
searchResultArea.setText( "# Name Seat" );
searchPanel = new JPanel();
panel2.add( searchPanel );
searchPanel.setBounds( 300, 5, 215, 300 );
searchPanel.setLayout( null );
searchPanel.setBorder( new TitledBorder( "Search" ) );
///////////////////////////////////////////////////
///////////////////////////////////////////////////
///////////////////////////////////////////////////
JLabel label3 = new JLabel( "panel three", SwingConstants.CENTER );
JPanel panel3 = new JPanel( null );
panel3.add( label3 );
tabbedPane.addTab( " SEAT CHART", null, panel3, "Seating Chart");
customerLabel = new JLabel( "Passengers" );
panel3.add( customerLabel );
customerLabel.setBounds( 250, 20, 100, 20 );
manifestArea = new JTextArea();
panel3.add( manifestArea);
manifestArea.setEditable( false );
manifestArea.setBounds( 250, 50, 300, 400 );
manifestArea.setText( "# Name\t\tMeal\tClass\tSeat \n" );
customerListScrollPane = new JScrollPane( manifestArea );
customerListScrollPane.setBounds( 10, 50, 650, 250 );
panel3.add( customerListScrollPane );
displayComboBox = new JComboBox( display );
panel3.add( displayComboBox );
displayComboBox.setBounds( 250, 300, 170, 20 );
displayComboBox.setSelectedIndex( 0 );
displayComboBox.addItemListener( new ItemListener(){
public void itemStateChanged( ItemEvent event ){
DisplayTypeChanged( event );
}
}
);
JLabel label4 = new JLabel( "panel three", SwingConstants.CENTER );
JPanel panel4 = new JPanel( null );
panel4.add( label4 );
tabbedPane.addTab( " CALCULATE TICKET PRICE", null, panel4, "FourthPanel");
BusinessClassJLabel = new JLabel();
BusinessClassJLabel.setIcon( new ImageIcon( "BusinessClass.jpg" ) );
BusinessClassJLabel.setBounds( 10, 100, 100, 100 );
BusinessClassJLabel.setHorizontalAlignment( JLabel.CENTER );
panel4.add( BusinessClassJLabel );
// set up nameJLabel
nameJLabel = new JLabel();
nameJLabel.setBounds( 26, 10, 130, 21 );
nameJLabel.setText( "Name:" );
panel4.add( nameJLabel );
// set up nameJTextField
nameJTextField = new JTextField();
nameJTextField.setBounds( 120, 10, 220, 21 );
nameJTextField.setText( "" );
panel4.add( nameJTextField );
// set up addressLine1JLabel
addressLine1JLabel = new JLabel();
addressLine1JLabel.setBounds( 26, 40, 120, 21 );
addressLine1JLabel.setText( "Address Line 1:" );
panel4.add( addressLine1JLabel );
// set up addressLine1JTextField
addressLine1JTextField = new JTextField();
addressLine1JTextField.setBounds( 120, 40, 220, 21 );
addressLine1JTextField.setText( "" );
panel4.add( addressLine1JTextField );
// set up addressLine2JLabel
addressLine2JLabel = new JLabel();
addressLine2JLabel.setBounds( 26, 70, 120, 21 );
addressLine2JLabel.setText( "Address Line 2:" );
panel4.add( addressLine2JLabel );
// set up addressLine2JTextField
addressLine2JTextField = new JTextField();
addressLine2JTextField.setBounds( 120, 70, 220, 21 );
addressLine2JTextField.setText( "" );
panel4.add( addressLine2JTextField );
// set up productNameJLabel
productNameJLabel = new JLabel();
productNameJLabel.setBounds( 26, 125, 64, 21 );
productNameJLabel.setText( "Product" );
panel4.add( productNameJLabel );
// set up productQuantityJLabel
productQuantityJLabel = new JLabel();
productQuantityJLabel.setBounds( 160, 125, 64, 21 );
productQuantityJLabel.setText( "Quantity" );
panel4.add( productQuantityJLabel );
// set up productPriceJLabel
productPriceJLabel = new JLabel();
productPriceJLabel.setBounds( 260, 125, 64, 21 );
productPriceJLabel.setText( "Price" );
panel4.add( productPriceJLabel );
// set up orderTotalsJLabel
orderTotalsJLabel = new JLabel();
orderTotalsJLabel.setBounds( 360, 125, 64, 21 );
orderTotalsJLabel.setText( "Totals" );
panel4.add( orderTotalsJLabel );
// set up BusinessClassJCheckBox
BusinessClassJCheckBox = new JCheckBox();
BusinessClassJCheckBox.setBounds( 26, 160, 122, 24 );
BusinessClassJCheckBox.setText( "BusinessClass" );
panel4.add( BusinessClassJCheckBox );
// set up EconomicClassJCheckBox
EconomicClassJCheckBox = new JCheckBox();
EconomicClassJCheckBox.setBounds( 26, 200, 122, 24 );
EconomicClassJCheckBox.setText( "EconomicClass" );
panel4.add( EconomicClassJCheckBox );
// set up BusinessClassquantityJTextField
BusinessClassquantityJTextField = new JTextField();
BusinessClassquantityJTextField.setBounds( 160, 160, 56, 21 );
BusinessClassquantityJTextField.setText( "0" );
BusinessClassquantityJTextField.setHorizontalAlignment( JTextField.CENTER );
panel4.add( BusinessClassquantityJTextField );
// set up EconomicClassquantityJTextField
EconomicClassquantityJTextField = new JTextField();
EconomicClassquantityJTextField.setBounds( 160, 200, 56, 21 );
EconomicClassquantityJTextField.setText( "0" );
EconomicClassquantityJTextField.setHorizontalAlignment( JTextField.CENTER );
panel4.add( EconomicClassquantityJTextField );
// set up BusinessClasspriceJTextField
BusinessClasspriceJTextField = new JTextField();
BusinessClasspriceJTextField.setBounds( 260, 160, 56, 21 );
BusinessClasspriceJTextField.setText( "$350.00" );
BusinessClasspriceJTextField.setEditable( false );
BusinessClasspriceJTextField.setHorizontalAlignment( JTextField.CENTER );
panel4.add( BusinessClasspriceJTextField );
// set up EconomicClasspriceJTextField
EconomicClasspriceJTextField = new JTextField();
EconomicClasspriceJTextField.setBounds( 260, 200, 56, 21 );
EconomicClasspriceJTextField.setText( "$125.00" );
EconomicClasspriceJTextField.setEditable( false );
EconomicClasspriceJTextField.setHorizontalAlignment( JTextField.CENTER );
panel4.add( EconomicClasspriceJTextField );
// set up BusinessClassTotalsJTextField
BusinessClassTotalsJTextField = new JTextField();
BusinessClassTotalsJTextField.setBounds( 360, 160, 56, 21 );
BusinessClassTotalsJTextField.setText( "$0.00" );
BusinessClassTotalsJTextField.setEditable( false );
BusinessClassTotalsJTextField.setHorizontalAlignment( JTextField.CENTER );
panel4.add( BusinessClassTotalsJTextField );
// set up EconomicClassTotalsJTextField
EconomicClassTotalsJTextField = new JTextField();
EconomicClassTotalsJTextField.setBounds( 360, 200, 56, 21 );
EconomicClassTotalsJTextField.setText( "$0.00" );
EconomicClassTotalsJTextField.setEditable( false );
EconomicClassTotalsJTextField.setHorizontalAlignment( JTextField.CENTER );
panel4.add( EconomicClassTotalsJTextField );
// set up subtotalJLabel
subtotalJLabel = new JLabel();
subtotalJLabel.setBounds( 30, 250, 134, 21 );
subtotalJLabel.setText( "Subtotal:" );
panel4.add( subtotalJLabel );
// set up subtotalJTextField
subtotalJTextField = new JTextField();
subtotalJTextField.setBounds( 160, 250, 56, 21 );
subtotalJTextField.setText( "$0.00" );
subtotalJTextField.setEditable( false );
subtotalJTextField.setHorizontalAlignment( JTextField.CENTER );
panel4.add( subtotalJTextField );
// set up vatJLabel
vatJLabel = new JLabel();
vatJLabel.setBounds( 30, 290, 134, 21 );
vatJLabel.setText( "VAT 17.5%:" );
panel4.add( vatJLabel );
// set up vatJTextField
vatJTextField = new JTextField();
vatJTextField.setBounds( 160, 290, 60, 21 );
vatJTextField.setText( "$0.00" );
vatJTextField.setEditable( false );
vatJTextField.setHorizontalAlignment( JTextField.CENTER );
panel4.add( vatJTextField );
// set up totalJLabel
totalJLabel = new JLabel();
totalJLabel.setBounds( 260, 250, 134, 21 );
totalJLabel.setText( "Total:" );
panel4.add( totalJLabel );
// set up totalJTextField
totalJTextField = new JTextField();
totalJTextField.setBounds( 360, 250, 60, 21 );
totalJTextField.setText( "$0.00" );
totalJTextField.setEditable( false );
totalJTextField.setHorizontalAlignment( JTextField.CENTER );
panel4.add( totalJTextField );
// set up calculateJButton
calculateJButton = new JButton();
calculateJButton.setBounds( 335, 280, 90, 24 );
calculateJButton.setText( "Calculate" );
panel4.add( calculateJButton );
calculateJButton.addActionListener(
new ActionListener()
{
public void actionPerformed (ActionEvent event)
{
calculateJButtonActionPerformed (event);
}
}
);
noData();
noDate();
getContentPane().add( tabbedPane );
setSize( 700,400 );
setVisible( true );
}
/////////////////////////////////////////
/////////////////////////////////////////
/////////////////////////////////////////
/////////////////////////////////////////
/////////////////////////////////////////
//method for enabling and disabling contents when no date is entered
public void noDate(){
dayComboBox.setEnabled( false );
newButton.setEnabled( true );
}
//method for enabling contents
public void dataEditable(){
editRadio.setEnabled( true );
searchRadio.setEnabled( true );
deleteButton.setEnabled( true );
deleteField.setEditable( true );
searchButton.setEnabled( true );
searchField.setEditable( true );
searchField1.setEditable( true );
editPanel.setVisible( false );
searchPanel.setVisible( false );
newButton.setEnabled( true );
displayComboBox.setEnabled( true );
}
//method for disabling contents if there is no data
public void noData(){
flightComboBox.setEnabled( false );
displayComboBox.setEnabled( false );
addButton.setEnabled( false );
saveButton.setEnabled( false );
deleteButton.setEnabled( false );
FirstNameField.setEditable( false );
LastNameField.setEditable( false );
classComboBox.setEnabled( false );
mealComboBox.setEnabled( false );
deleteField.setEditable( false );
searchButton.setEnabled( false );
searchField.setEditable( false );
searchField1.setEditable( false );
ticketButton.setEnabled( false );
searchPanel.setVisible( false );
editPanel.setVisible( false );
newButton.setEnabled( true );
displayComboBox.setEnabled( false );
editRadio.setEnabled( false );
searchRadio.setEnabled( false );
}
public void noData1(){
flightComboBox.setEnabled( true );
displayComboBox.setEnabled( false );
addButton.setEnabled( false );
saveButton.setEnabled( false );
deleteButton.setEnabled( false );
FirstNameField.setEditable( false );
LastNameField.setEditable( false );
classComboBox.setEnabled( false );
mealComboBox.setEnabled( false );
deleteField.setEditable( false );
searchButton.setEnabled( false );
searchField.setEditable( false );
searchField1.setEditable( false );
ticketButton.setEnabled( false );
searchPanel.setVisible( false );
editPanel.setVisible( false );
newButton.setEnabled( true );
displayComboBox.setEnabled( false );
editRadio.setEnabled( false );
searchRadio.setEnabled( false );
}
//method for selecting day and setting the flight number
public void resetSeatCounters(){
aisleCount = 0;
rowCount = 1;
businessClassAisleCount = 0;
businessClassRowCount = 6;
}
public void FlightDayChanged( ItemEvent event){
if( ( event.getStateChange() == ItemEvent.SELECTED ) &&
dayComboBox.getSelectedIndex() != 0 ){
addButton.setEnabled( true );
saveButton.setEnabled( true );
loadButton.setEnabled( true );
FirstNameField.setEditable( true );
LastNameField.setEditable( true );
classComboBox.setEnabled( true );
mealComboBox.setEnabled( true );
//flightComboBox.setEnabled( true );
if( dayComboBox.getSelectedIndex() == 1 ){
ResetFlightNum();
if ( flightComboBox.getSelectedIndex() == 1 )
flightNum += "1";
else
flightNum += "2";
flightNum += "MO";
}
if( dayComboBox.getSelectedIndex() == 2 ){
ResetFlightNum();
if ( flightComboBox.getSelectedIndex() == 1 )
flightNum += "1";
else
flightNum += "2";
flightNum += "TU";
}
if( dayComboBox.getSelectedIndex() == 3 ){
ResetFlightNum();
if ( flightComboBox.getSelectedIndex() == 1 )
flightNum += "1";
else
flightNum += "2";
flightNum += "WE";
}
if( dayComboBox.getSelectedIndex() == 4 ){
ResetFlightNum();
if ( flightComboBox.getSelectedIndex() == 1 )
flightNum += "1";
else
flightNum += "2";
flightNum += "TH";
}
if( dayComboBox.getSelectedIndex() == 5 ){
ResetFlightNum();
if ( flightComboBox.getSelectedIndex() == 1 )
flightNum += "1";
else
flightNum += "2";
flightNum += "FR";
}
}
else
noData1();
}
//method actions of JRadioButtons
public void FlightDestinationChanged( ItemEvent event){
if( ( event.getStateChange() == ItemEvent.SELECTED ) &&
flightComboBox.getSelectedIndex() != 0 ){
dayComboBox.setEnabled( true );
}
else
noData1();
}
public void EditTypeChanged( ItemEvent event){
try{
if ( editField.getText().equals( "" ) ){
JOptionPane.showMessageDialog( this,
"Please choose a valid record" + " to edit" );
editComboBox.setSelectedIndex( 0 );
}
else if( ( event.getStateChange() == ItemEvent.SELECTED ) &&
editComboBox.getSelectedIndex() != 0 ){
if( editComboBox.getSelectedIndex() == 1 ){
changeNameField.setVisible( true );
changeNameField.setEditable( true );
mealComboBox1.setVisible( false );
}
if( editComboBox.getSelectedIndex() == 2 ){
changeNameField.setVisible( true );
changeNameField.setEditable( true );
mealComboBox1.setVisible( false );
}
if( editComboBox.getSelectedIndex() == 3 ){
changeNameField.setVisible( false );
changeNameField.setEditable( false );
mealComboBox1.setVisible( true );
}
}
}
catch(NumberFormatException numberFormatException)
{
JOptionPane.showMessageDialog( this,
"Please enter record number!", "Input Error",
JOptionPane.INFORMATION_MESSAGE );
}
}
public void DisplayTypeChanged( ItemEvent event ){
if( ( event.getStateChange() == ItemEvent.SELECTED ) ){
if( displayComboBox.getSelectedIndex() == 0 ){
displayManifest();
}
if( displayComboBox.getSelectedIndex() == 1 ){
displaySeatingChart();
}
}
}
public void editData(){
if( editComboBox.getSelectedIndex() == 1 ){
editName();
}
if( editComboBox.getSelectedIndex() == 2 ){
editLastName();
}
if( editComboBox.getSelectedIndex() == 3 ){
editMeal();
}
}
//method for adding customer to array List and displaying information
private class SelectedInputRadio implements ItemListener{
public void itemStateChanged( ItemEvent e){
mainPanel.setVisible( true );
editPanel.setVisible( false );
searchPanel.setVisible(false);
}
}
private class SelectedEditRadio implements ItemListener{
public void itemStateChanged( ItemEvent e){
mainPanel.setVisible( false );
searchPanel.setVisible( false );
editPanel.setVisible( true );
}
}
private class SelectedSearchRadio implements ItemListener{
public void itemStateChanged( ItemEvent e){
mainPanel.setVisible( false );
editPanel.setVisible(false);
searchPanel.setVisible( true );
}
}
public void addCustomer(){
if( count < size - 1 ){
String name = FirstNameField.getText();
String LastName = LastNameField.getText();
String mealT = meal[ mealComboBox.getSelectedIndex() ];
String classt = classS[ classComboBox.getSelectedIndex() ];
String seatChosen = returnSeat( classComboBox.getSelectedIndex() );
//check if data has been entered
if ( name.equals( "" ) || LastName.equals( "" ) || mealComboBox.getSelectedIndex() == 0
|| classComboBox.getSelectedIndex() == 0 ){
JOptionPane.showMessageDialog( null, "Please enter in all of" +
" the information for this passenger" );
resetSeatCounters();
}
else if( seatChosen.equals( "" ) )
JOptionPane.showMessageDialog( null, "Class Full" );
else{
count++;
List[ count ] = new PassengerData( name, LastName, mealT, seatChosen, classt, flightNum, 1 );
records++;
FirstNameField.setText( "" );
LastNameField.setText( "" );
//create string for display
outputManifest = ( count + 1 ) + ". " + List[ count ].getLastName() +
", " + List[ count ].getFirstName() + "\t\t" + List[ count ].getMealType() + "\t" + classt +
"\t" + List[ count ].getSeat() + "\n";
FirstNameField.requestFocusInWindow();
customerArea.append( outputManifest );//display string output
dataEditable();
}
//create error message if plane is full
if( count == ( size - 1 ) ){
JOptionPane.showMessageDialog( null, "The plane is full" );
FirstNameField.setEditable( false );
LastNameField.setEditable( false );
mealComboBox.setEnabled( false );
classComboBox.setEnabled( false );
addButton.setEnabled( false );
saveButton.setEnabled( true );
}
mealComboBox.setSelectedIndex( 0 );
classComboBox.setSelectedIndex( 0 );
flightField.setText( flightNum );
dayComboBox.setEnabled( false );
flightComboBox.setEnabled( false );
saveButton.setEnabled( true );
}
}
//method for initializing string flightNum
public void ResetFlightNum(){
flightNum = "RE-";
}
public String returnSeat( int classC ){
String seatReturn;
int aisle = 0;
int row = 0;
if( classC == 1 ){
aisleCount++;
if( aisleCount == 5 ){
rowCount++;
aisleCount = 1;
if( rowCount == 6 ){
rowCount = 12;
}
}
aisle = aisleCount;
row = rowCount;
}
else if( classC == 2){
businessClassAisleCount++;
if( businessClassAisleCount == 5 ){
businessClassRowCount++;
businessClassAisleCount = 1;
if( businessClassRowCount == 12 ){
rowCount = 13;
}
}
aisle = businessClassAisleCount;
row = businessClassRowCount;
}
if( row == 12 || row == 13 ){
seatReturn = "";
}
else{
seatReturn = "Row: " + row + " Seat: " + aisle;
}
return seatReturn;
}
//method for opening files for loading List
public boolean OpenFile(){
JFileChooser fileChooser = new JFileChooser();
fileChooser.setFileSelectionMode( JFileChooser.FILES_ONLY );
int result = fileChooser.showOpenDialog( this );
if ( result == JFileChooser.CANCEL_OPTION )
return false;
File fileName = fileChooser.getSelectedFile();
//display error messages if any errors occur while loading the file
if ( fileName == null || fileName.getName().equals( "" ) )
JOptionPane.showMessageDialog( this, "Invalid File Name",
"Invalid File Name", JOptionPane.ERROR_MESSAGE );
else{
try{
recordedfile = new ObjectInputStream( new FileInputStream( fileName ) );
return true;
}
catch ( IOException ioException ) {
JOptionPane.showMessageDialog( this, "Error Opening File",
"Error", JOptionPane.ERROR_MESSAGE );
}
}
return true;
}
//method for opening the file for saving list
public void OpenFile1(){
JFileChooser fileChooser = new JFileChooser();
fileChooser.setFileSelectionMode( JFileChooser.FILES_ONLY );
fileChooser.setDialogType( JFileChooser.SAVE_DIALOG );
int result = fileChooser.showOpenDialog( this );
if ( result == JFileChooser.CANCEL_OPTION )
return;
File fileName = fileChooser.getSelectedFile();
if ( fileName == null || fileName.getName().equals( "" ) )
JOptionPane.showMessageDialog( this, "Invalid File Name",
"Invalid File Name", JOptionPane.ERROR_MESSAGE );
else{
try{
recordfile = new ObjectOutputStream( new FileOutputStream( fileName ) );
}
catch ( IOException ioException ) {
JOptionPane.showMessageDialog( this, "Error Opening File",
"Error", JOptionPane.ERROR_MESSAGE );
}
}
}
//method for saving information
public void SaveToFile( ActionEvent event ){
boolean done = false;
for( int counter = 0; counter < records; counter++ ){
try{//save list and flight num to database
recordfile.writeObject( List[ counter ] );
recordfile.writeObject( flightNum );
recordfile.flush();
done = true;
}
catch( IOException ioException ){
JOptionPane.showMessageDialog( this, "Error writing to file",
"IO Exception", JOptionPane.ERROR_MESSAGE);
CloseFile();
}
}
if( done ){
JOptionPane.showMessageDialog( this, "Records Saved!!!",
"File Access", JOptionPane.INFORMATION_MESSAGE );
saveButton.setEnabled( false );
}
dayComboBox.setEnabled( false );
flightComboBox.setEnabled( false );
}
//close file after loading or saving is done
public void CloseFile(){
try{
recordfile.close();
System.exit( 0 );
}
catch( IOException ioException ){
JOptionPane.showMessageDialog( this, "Error Closing File", "Error",
JOptionPane.ERROR_MESSAGE );
System.exit( 1 );
}
}
//method for loading information from an existing file
public void LoadFromFile(ActionEvent event){
boolean done = false;
count = -1;
while( !done ){
count++;
try{
List[ count ] = ( PassengerData ) recordedfile.readObject();
flightNum = ( String ) recordedfile.readObject();
}
catch( EOFException endOfFileException ){
JOptionPane.showMessageDialog( this,
"All records loaded from file!", "End of File",
JOptionPane.INFORMATION_MESSAGE );
done = true;
}
catch( ClassNotFoundException classNotFoundException ){
JOptionPane.showMessageDialog( this, "Unable to create object!",
"Class Not Found", JOptionPane.ERROR_MESSAGE );
}
catch( IOException ioException ){
JOptionPane.showMessageDialog( this,
"Error during read from file!", "Read Error",
JOptionPane.ERROR_MESSAGE );
}
}
addButton.setEnabled( true );
deleteButton.setEnabled( true );
dayComboBox.setEnabled( false );
flightComboBox.setEnabled( false );
dataEntryAllowed();
displayInfo();
}
//clear data when creating new list of passengers
public void ClearData(){
FirstNameField.setText( "" );
LastNameField.setText( "" );
mealComboBox.setSelectedIndex( 0 );
classComboBox.setSelectedIndex( 0 );
customerArea.setText( "# Name\t\tMeal\tClass\tSeat \n" );
flightField.setText( "" );
deleteField.setText( "" );
searchField.setText( "" );
searchField1.setText( "" );
dayComboBox.setSelectedIndex( 0 );
if ( flightComboBox.getSelectedIndex() == 1 )
flightComboBox.setSelectedIndex( 0 );
noData();
noDate();
}
//allow data to be entered
public void dataEntryAllowed(){
FirstNameField.setEditable( true );
LastNameField.setEditable( true );
mealComboBox.setEnabled( true );
classComboBox.setEnabled( true );
}
public void displaySeatingChart(){
String seat;
String output;
int aisle;
int row;
PassengerData seating[][] = new PassengerData[11][4];
for( int rows = 0; rows < 11; rows++){
for( int column = 0; column < 4; column++ ){
seating[ rows ][ column ] = new PassengerData( "", "", "", "", "", "", 0 );
}
}
output = "\tSeat 1\tSeat 2\tSeat 3\tSeat 4\n\n";
for( int counter = 0; counter <= count; counter++ ){
seat = List[ counter ].getSeat();
row = Integer.parseInt(seat.substring( 5, 6 ));
aisle = Integer.parseInt( seat.substring( 13 , 14 ) );
seating[row - 1][aisle - 1] = List[ counter ];
}
for( int rows = 0; rows < 11; rows++){
output += "Row " + ( rows + 1 ) + "\t ";
if( rows == 6)
output += "------------Business Class-------------\nRow " + ( rows + 1 ) + "\t ";
for( int column = 0; column < 4; column++ ){
if( seating[rows][column].getCheckEnter() == 0 )
output += "Empty Seat\t";
else{
if( column == 1 ){
output += seating[rows][column].getLastName().toUpperCase() + ", " +
seating[rows][column].getFirstName().toUpperCase() + "\t";
}
else{
output += seating[rows][column].getLastName().toUpperCase() + ", " +
seating[rows][column].getFirstName().toUpperCase() + "\t";
}
}
}
output += "\n\n";
}
customerArea.setText( output );
}
//display information when a file has been loaded
public void displayManifest(){
String output = "# Name\t\tMeal\tClass\tSeat \n";
for( int counter = 0; counter <= count; counter++ ){
output += ( counter + 1 ) + ". " + List[ counter ].getLastName() +
", " + List[ counter ].getFirstName() + "\t\t" +
List[ counter ].getMealType() +
"\t" + List[ counter ].getClassType() + "\t" + List[ counter ].getSeat() + "\n";
}
customerArea.setText( output );
}
public void displayInfo(){
flightField.setText( flightNum );
String output = "# Name\t\tMeal\tClass\tSeat \n";
customerArea.setText( output );
for( int counter = 0; counter < count; counter++ ){
output = ( counter + 1 ) + ". " + List[ counter ].getLastName() +
", " + List[ counter ].getFirstName() + "\t\t" +
List[ counter ].getMealType() +
"\t" + List[ counter ].getClassType() + "\t" + List[ counter ].getSeat() + "\n";
customerArea.append( output );
}
}
//delete an existing record on list
public void deleteRecord(){
//displays error message if incorrect int or data entered
try{
int record = Integer.parseInt( deleteField.getText() );
if ( record > records )
JOptionPane.showMessageDialog( null, "Record number " + record
+ " does not exist" );
else{
List[ record - 1 ] = List[ records - 1 ];
displayInfo();
count--;
records--;
if( records == 0 ){
searchRadio.setEnabled( false );
mainPanel.setVisible( true );
editPanel.setVisible( false );
editRadio.setEnabled( false );
inputRadio.setSelected( true );
}
saveButton.setEnabled( true );
}
}
catch(NumberFormatException numberFormatException){
JOptionPane.showMessageDialog( this,
"Please enter record number!", "Input Error",
JOptionPane.INFORMATION_MESSAGE );
}
}
//edit name at specific record
public void editName(){
try
{
int edit = Integer.parseInt( editField.getText() );
if ( editField.getText().equals( "" ) || edit > records )
JOptionPane.showMessageDialog( null,
"Please choose a valid record" + " to edit" );
else{
String name = changeNameField.getText();
String LastName = List[ edit - 1 ].getLastName();
String meal = List[ edit - 1 ].getMealType();
String seat = List[ edit - 1 ].getSeat();
String classT = List[ edit - 1 ].getClassType();
if ( name.equals( "" ) )
JOptionPane.showMessageDialog( null,
"Please enter in all of" + " the information required" );
else{
List[ edit - 1 ] =
new PassengerData( name, LastName, meal, seat, classT, flightNum, 1 );
count++;
displayInfo();
count--;
saveButton.setEnabled( true );
}
}
}
catch(NumberFormatException numberFormatException)
{
JOptionPane.showMessageDialog( this,
"Please enter record number!", "Input Error",
JOptionPane.INFORMATION_MESSAGE );
}
}
//edit last name at a specific record
public void editLastName(){
try{
int edit = Integer.parseInt( editField.getText() );
if ( editField.getText().equals( "" ) || edit > records )
JOptionPane.showMessageDialog( null, "Please choose a valid record" +
" to edit" );
else{
String name = List[ edit - 1 ].getFirstName();
String LastName = changeNameField.getText();
String meal = List[ edit - 1 ].getMealType();
String seat = List[ edit - 1 ].getSeat();
String classT = List[ edit - 1].getClassType();
if ( LastName.equals( "" ) )
JOptionPane.showMessageDialog( null, "Please enter in all of" +
" the information required" );
else{
List[ edit - 1 ] = new PassengerData( name, LastName, meal, seat, classT, flightNum, 1 );
count++;
displayInfo();
count--;
saveButton.setEnabled( true );
}
}
}
catch(NumberFormatException numberFormatException){
JOptionPane.showMessageDialog( this,
"Please enter record number!", "Input Error",
JOptionPane.INFORMATION_MESSAGE );
}
}
//edit meal at a specific record
public void editMeal(){
try{
int edit = Integer.parseInt( editField.getText() );
if ( editField.getText().equals( "" ) || edit > records )
JOptionPane.showMessageDialog( null, "Please choose a valid record" +
" to edit" );
else{
String name = List[ edit - 1 ].getFirstName();
String LastName = List[ edit - 1 ].getLastName();
String mealC = meal[ mealComboBox1.getSelectedIndex() ];
String seat = List[ edit - 1 ].getSeat();
String classT = List[ edit - 1].getClassType();
if ( meal.equals( "" ) )
JOptionPane.showMessageDialog( null, "Please enter in all of" +
" the information required" );
else{
List[ edit - 1 ] = new PassengerData( name, LastName, mealC, seat, classT, flightNum, 1 );
count++;
displayInfo();
count--;
saveButton.setEnabled( true );
}
}
}
catch(NumberFormatException numberFormatException)
{
JOptionPane.showMessageDialog( this,
"Please enter record number!", "Input Error",
JOptionPane.INFORMATION_MESSAGE );
}
}
//edit seat number at a specific record
public void editSeat(){
try{
int edit = Integer.parseInt( editField.getText() );
if ( editField.getText().equals( "" ) || edit > records )
JOptionPane.showMessageDialog( null, "Please choose a valid record" +
" to edit" );
else{
String name = List[ edit - 1 ].getFirstName();
String LastName = List[ edit - 1 ].getLastName();
String meal = List[ edit - 1 ].getMealType();
String seat = changeNameField.getText();
String classT = List[ edit - 1].getClassType();
if ( seat.equals( "" ) )
JOptionPane.showMessageDialog( null, "Please enter in all of" +
" the information required" );
else{
List[ edit - 1 ] = new PassengerData( name, LastName, meal, seat, classT, flightNum, 1 );
count++;
displayInfo();
count--;
saveButton.setEnabled( true );
}
}
}
catch(NumberFormatException numberFormatException)
{
JOptionPane.showMessageDialog( this,
"Please enter record number!", "Input Error",
JOptionPane.INFORMATION_MESSAGE );
}
}
//search for record
public void searchRecord(){
String output = "";
String key = searchField.getText() + " " + searchField1.getText() ;
int found = 0;
//display an error message if information not filled in
if( searchField.getText().equals( "" ) )
JOptionPane.showMessageDialog( null, "Please enter the First name" );
else if ( searchField1.getText().equals( "" ) )
JOptionPane.showMessageDialog( null, "Please enter the Last name" );
else{
for( int count = 0; count <= records - 1; count++ ){
if ( key.equals( List[ count ].getFirstName() + " " +
List[ count ].getLastName() ) )
found = count + 1;
}
if ( found != 0 ){
output = "\n" + found + key + List[ found - 1 ].getSeat();
searchResultArea.append( output );
searchCounter = found - 1;
}
else
searchResultArea.append("\nCustomer not found");
}
}
//compares seat entered to seat numbers on list to check if already exists
public void checkSeat1(){
String seat = changeNameField.getText();
boolean found = false;
for ( int count = 0; count < records; count ++ )
if ( seat.equals( List[ count ].getSeat() ) )
found = true;
if( found == true )
JOptionPane.showMessageDialog( null, "The seat entered has already" +
" been reserved" );
else
editSeat();
}
public static void main( String args[] )
{
AirBox tabbedPaneDemo = new AirBox();
tabbedPaneDemo.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
}
}[/PHP]