Creating the User Interface for the Airline Reservation Application


The ReservationStatus.java file creates the user interface for the Airline Reservation application. Listing 6-3 shows the contents of the ReservationStatus.java file:

Listing 6-3: The ReservationStatus.java File

start example
 /*Imports required swing classes*/ import javax.swing.*; /*Imports required Applet class*/ import java.applet.Applet; /*Imports required awt classes*/ import java.awt.*; import java.awt.event.*; /*Imports required i/o classes*/ import java.io.*; /*Imports required net classes*/ import java.net.*; /*Imports required util classes*/ import java.util.*; /*Imports required swing classes*/ import javax.swing.table.*; import javax.swing.JTextPane; import javax.swing.text.*; /*Imports required Vector class*/ import java.util.Vector; import javax.swing.table.AbstractTableModel; import javax.swing.event.*; /* class ReservationStatus - This class is the main class of the application. This class initializes the interface and loads all components like the button and textfields before displaying the result. Constructor: ReservationStatus-This constructor creates GUI. Methods: setTableContent - Sets search result into table. validation - This method is used to validate user input. */ public class ReservationStatus extends JApplet  implements ActionListener {    /*Declare objects of JComboBox class.*/    JComboBox fromcombobox;    JComboBox tocombobox;    JComboBox todaycombobox;    JComboBox tomonthcombobox;    JComboBox toyearcombobox;    JComboBox fromdaycombobox;    JComboBox frommonthcombobox;    JComboBox fromyearcombobox;    /*Declare objects of JLabel class.*/    JLabel fromlabel;    JLabel tolabel;    JLabel fromdatelabel;    JLabel todatelabel;    /*Declare object of JButton class.*/    JButton searchbutton;    /*Declare object of Container class.*/    Container contentpane;    /*Declare object of String class.*/    String TodayDate;    /*Declare array of String class.*/    String[] spleteddate;    /*Declare objects of JRadioButton class.*/    JRadioButton iradio;    JRadioButton nriradio;    /*Declare object of Vector class.*/    Vector idvector;    /*Declare object of String class.*/    String servername="localhost";    /*Declare object of SocketClass class.*/    SocketClass socketclass;    /*Declare objects of String class.*/    String passportno="100001";    String city;    String username;    String emailid;    String address;    /*Declare object of JButton class.*/    JButton submitbutton;    /*Declare object of JCheckBox class.*/    JCheckBox roundtrip;    /*Declare objects of Vector class.*/    Vector evector;    Vector gvector;    /*Declare integer variable*/    int selectedrow;    /*Declare object of MyTableReservation class.*/    TableModelReservation mytable;    /*Declare object of ReservationResultTable class.*/    ReservationResultTable t;    /*    This method initializes the object variables in the applet.     */    public void init()    {    contentpane=getContentPane();    /*Set the BorderLayout to the applet.*/    contentpane.setLayout(new BorderLayout());    /*    Initialize and set the Look and Feel of the application to Windows Look and Feel.    */    try    {       UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());    }    catch(Exception e)    {       System.out.println("Unable to set WLF"+e);    }    /* Initialize the objects of Vector class. */    evector=new Vector();    gvector=new Vector();    city=getParameter("city");    username=getParameter("firstname")+getParameter("lastname");    emailid=getParameter("emailid");    address=getParameter("address");    /*    Declare and initialize the object of JPanel class.    */    JPanel mainpanel=new JPanel();    /*    Declare and initialize the object of GridLayout class.    */    GridLayout mainlayout=new GridLayout(2, 2, 5, 5);     /*Set the Gridlayout to mainpanel object.*/    mainpanel.setLayout(mainlayout);    /*    Declare and initialize the object of JPanel class.    */    JPanel citypanel=new JPanel();    /*    Declare and initialize the object of GridLayout class.    */    GridLayout citylayout=new GridLayout(4, 1, 15, 5);    /*Set the Gridlayout to citypanel object.*/    citypanel.setLayout(citylayout);    /*Initializes the object of JComboBox class.*/    fromcombobox=new JComboBox();    /*Add the items to the object of JComboBox class.*/    fromcombobox.addItem("Chicago");    fromcombobox.addItem("Boston");    fromcombobox.addItem("Denver");    /*Initializes the object of JLabel class.*/    fromlabel=new JLabel("From",JLabel.CENTER);    /*Sets the font to the object of JLabel class.*/    fromlabel.setFont(new Font("verdana", 1, 12));    /*    Adds the object of the JLabel class to the object JPanel class.    */    citypanel.add(fromlabel);    /*    Declares and initializes the object of JPanel class.    */    JPanel fromcombopanel=new JPanel();    /* Sets the size of the object of JComboBox class.*/    fromcombobox.setPreferredSize(new Dimension(200, 20));    /*    Adds the object of JComboBox class to object of JPanel class.    */    fromcombopanel.add(fromcombobox);    /*    Adds the objects of JPanel class to object of JPanel class.    */    citypanel.add(fromcombopanel);    mainpanel.add(citypanel);    /*    Declares and initializes the object of JPanel class.    */    JPanel citypanelto=new JPanel(new GridLayout(4,1,15,5));    /*Initializes the object of JLabel class*/    tolabel=new JLabel("To",JLabel.CENTER);    /*Sets the font of the object of JLabel class.*/    tolabel.setFont(new Font("verdana",1,12));    /* Adds the object of JLabel class to the object of JPanel class.*/    citypanelto.add(tolabel);    /*Initializes the object of JComboBox class.*/    tocombobox=new JComboBox();    /*Add items to the object of JComboBox class.*/    tocombobox.addItem("Chicago");    tocombobox.addItem("Boston");    tocombobox.addItem("Denver");    /*    Sets the preferred size of the object of JComboBox class.    */    tocombobox.setPreferredSize(new Dimension(200, 20));    /*    Declares and initializes the object of JPanel class.    */    JPanel tocombopanel=new JPanel();    /*    Adds the object of JCombobox class to the object of JPanel class.    */    tocombopanel.add(tocombobox);    /*    Adds the object of JPanel class to the object of JPanel class.    */    citypanelto.add(tocombopanel);    /*Initializes the object of the JCheckBox class.*/    roundtrip=new JCheckBox(" Round trip");    /*Sets the font of the object of JCheckBox class.*/    roundtrip.setFont(new Font("verdana",1,12));    /*    Adds the ItemListener to the object of JCheckBox class.    */    roundtrip.addItemListener(new ItemListener()     {       public void itemStateChanged(ItemEvent e)        {       if (e.getStateChange() == ItemEvent.SELECTED)       {          todaycombobox.setEnabled(true);          tomonthcombobox.setEnabled(true);          toyearcombobox.setEnabled(true);       }       else       {          todaycombobox.setEnabled(false);          tomonthcombobox.setEnabled(false);          toyearcombobox.setEnabled(false);       }    } }); /* Declares and Initializes the object of the JPanel class. */ JPanel roundtrippanel=new JPanel(); /* Adds the object of the JCheckBox class to the object of JPanel class. */ roundtrippanel.add(roundtrip); /* Adds the object of JPanel class to the object of the JPanel class. */ citypanelto.add(roundtrippanel); /* Initialize the objects of JComboBox class. */ todaycombobox=new JComboBox(); tomonthcombobox=new JComboBox(); toyearcombobox=new JComboBox(); /* Declares and Initializes the object of JPanel class. */ JPanel todaypanel=new JPanel(); todaycombobox.setEnabled(false); tomonthcombobox.setEnabled(false); toyearcombobox.setEnabled(false); /*Sets the size of the object of JComboBox class.*/ todaycombobox.setPreferredSize(new Dimension(40, 20)); /*Calls the addDays() function.*/ addDays(todaycombobox); /*Sets the size of the object of JComboBox class.*/ tomonthcombobox.setPreferredSize(new Dimension(70, 20)); /*Calls the addMonths() function.*/ addMonths(tomonthcombobox); /*Sets the size of the object of JComboBox class.*/ toyearcombobox.setPreferredSize(new Dimension(50, 20)); /*Calls the addYears() function.*/ addYears(toyearcombobox); /* Adds the objects of JComboBox class to the object of JPanel class. */ todaypanel.add(todaycombobox); todaypanel.add(tomonthcombobox); todaypanel.add(toyearcombobox); /* Adds the object of JPanel class to the object of JPanel class. */ citypanelto.add(todaypanel); /* Adds the object of JPanel class to the object of JPanel class. */ mainpanel.add(citypanelto); /*Initializes the object of the JLabel class.*/ fromdatelabel=new JLabel("Departure Date", JLabel.CENTER); fromdatelabel.setFont(new Font("verdana", 1, 12)); /* Adds the object of JLabel class to the object of JPanel class. */ /* Initializes the objects of JComboBox class.*/ citypanel.add(fromdatelabel); fromdaycombobox=new JComboBox(); frommonthcombobox=new JComboBox(); fromyearcombobox=new JComboBox(); /* Declares and Initializes the object of JPanel class. */ JPanel fromdaypanel=new JPanel(); /*Sets the size of the object of JComboBox class.*/ fromdaycombobox.setPreferredSize(new Dimension(40, 20)); /*Calls the addDays() function.*/ addDays(fromdaycombobox); /*Sets the size of the object of JComboBox class.*/ frommonthcombobox.setPreferredSize(new Dimension(70, 20)); /*Calls the addMonths() function.*/ addMonths(frommonthcombobox); /*Sets the size of the object of JComboBox class.*/ fromyearcombobox.setPreferredSize(new Dimension(50, 20)); /*Calls the addMonths() function.*/ addYears(fromyearcombobox); /* Adds the objects of JComboBox class to the object of JPanel class. */ fromdaypanel.add(fromdaycombobox); fromdaypanel.add(frommonthcombobox); fromdaypanel.add(fromyearcombobox); citypanel.add(fromdaypanel); /* Declares and Initializes the object of JPanel class. */ JPanel nationalitypanel=new JPanel(); /* Declares and Initializes the object of ButtonGroup class. */ ButtonGroup nationalitygroup = new ButtonGroup(); /*Initializes the objects of JRadioButton class.*/ iradio=new JRadioButton("US Citizen"); iradio.setSelected(true); /*Initializes the objects of JRadioButton class.*/ nriradio=new JRadioButton("Foreigner"); /* Declares and Initializes the object of JPanel class. */ JPanel subnationalitypanel=new JPanel(new GridLayout(3, 1, 0, 0)); /* Declares and Initializes the object of JLabel class. */ JLabel nationalitylabel=new JLabel("Nationality"); /*Sets the font of the object of the JLabel class.*/ nationalitylabel.setFont(new Font("verdana", 1, 12)); /* Adds the object of the JLabel class to the object of the JPanel class. */ subnationalitypanel.add(nationalitylabel); /* Adds the objects of the JRadioButton class to the object of ButtonGroup class. */ nationalitygroup.add(iradio); nationalitygroup.add(nriradio); /* Adds the objects of the JRadioButton class to the object of JPanel class. */ subnationalitypanel.add(iradio); subnationalitypanel.add(nriradio); /* Adds the objects of the JPanel class to the object of JPanel class. */ nationalitypanel.add(subnationalitypanel); mainpanel.add(nationalitypanel); /* Adds the object of the JPanel class to the object of ContentPane object. */ contentpane.add(mainpanel); /*Initializes the object of JButton class.*/ searchbutton=new JButton("Search"); /* Sets the ActionCommand of the object of JButton class. */ searchbutton.setActionCommand("search"); searchbutton.setMnemonic('s'); /* Adds the ActionListener to the object of the JButton class. */ searchbutton.addActionListener(this); /* Declares and Initializes the object of JPanel class. */ JPanel buttonpanel=new JPanel(); /* Sets the Flowlayout of the object of JPanel class. */ buttonpanel.setLayout(new FlowLayout()); /* Declares and Initializes the object of JButton class. */ JButton resetbutton=new JButton("Reset"); /* Sets the ActionCommand of the object of JButton class. */ resetbutton.setActionCommand("reset"); resetbutton.setMnemonic('r'); /* Adds the ActionListener to the object of the JButton class. */ resetbutton.addActionListener(this); /* Sets the size of the object of the JButton class  */ resetbutton.setPreferredSize(new Dimension(80,20)); /* Initializes the object of ReservationResultTable class. */ t=new ReservationResultTable(); /* Sets the size of the object of the ReservationResultTable class. */ t.setPreferredSize(new Dimension(300, 100));  /* Declares and Initializes the object of JPanel class. */ JPanel bpanel=new JPanel(new BorderLayout()); /* Declares and Initializes the object of JPanel class. */ JPanel topsubmitbuttonpanel=new JPanel(); /* Adds the objects of JButton class to the object of the JPanel class. */ topsubmitbuttonpanel.add(searchbutton); topsubmitbuttonpanel.add(resetbutton); bpanel.add(topsubmitbuttonpanel,BorderLayout.NORTH); /* Sets the size of the object of the JButton class. */ searchbutton.setPreferredSize(new Dimension(80, 20)); /* Adds the object of ReservationResultTable class to the object of the JPanel class. */ bpanel.add(t,BorderLayout.CENTER); /* Initializes the object of JButton class.*/ submitbutton=new JButton("Submit"); /* Sets the ActionCommand of the object of JButton class. */ submitbutton.setActionCommand("submit"); submitbutton.setMnemonic('u'); /* Adds the ActionListener to the object of the JButton class. */ submitbutton.addActionListener(this); submitbutton.setEnabled(false); /* Adds the object of JButton class to the object of the JPanel class. */ bpanel.add(submitbutton,BorderLayout.SOUTH); /* Adds the object of JPanel class to the object of the ContentPane class. */ contentpane.add(bpanel,BorderLayout.SOUTH); setSize(650,340); /* Initializes the object of SocketClass class.*/ socketclass=new SocketClass("localhost", 5222, 1000,this); } public String getUserName() {    return username; } /* setTableContent - Inserts the search result data into the table. Parameters:messagebody - object of String class. Return Value: NA */ public void setTableContent(String messagebody) { if (messagebody.trim().equals("No matching record found")) {    JOptionPane.showMessageDialog(null,messagebody,"Dialog box",JOptionPane.PLAIN_MESSAGE);    submitbutton.setEnabled(false);    return; } if(messagebody.indexOf("@")>0) {    String[] spletedschedule=messagebody.split("@");    submitbutton.setEnabled(true);    idvector=new Vector();    Object[][] object=new Object[spletedschedule.length][];    for (int i=0;i<spletedschedule.length;i++ )    {       String[] sp=spletedschedule[i].split("#");       object[i]=new Object[sp.length-1];       for (int j=0;j<sp.length-3;j++ )       {          String[] splitedvalue=sp[j].split("=");          if (splitedvalue.length==2)          {             if (splitedvalue[1].equals("YES"))             {                object[i][j]=new Boolean(false);             }             else             {                if (splitedvalue[1].equals("NO"))                {                   object[i][j]="NA";                }                else                {                   object[i][j]=splitedvalue[1];                }             }          }          idvector.add(sp[sp.length-3]);          evector.add(sp[sp.length-2]);          gvector.add(sp[sp.length-1]);       }    }    mytable= new TableModelReservation();    mytable.setData(object);    t.table.setModel(mytable); } } /* class TableModelReservation - This class is the main class of the application. This class initializes the interface and loads all components like the button, textfields before displaying the result. Methods: setData - Sets Object array to table object. getRowCount - This method returns the total number of rows. getColumnName - This method returns the Column name. getValueAt - This method returns the value at a particular cell location. setValueAt - This method sets the value at a particular cell location. */ class TableModelReservation extends AbstractTableModel  {    private String[] columnNames = {"Choice","Flight No.",    "Aircraft type",    "Origin",    "No. of Stops",    "Destination",    "Dep.Date-time",    "Arr.Date-time",    "Executive Class",    "Economy Class", }; private Object[][] data = {}; public int getColumnCount()  {    return columnNames.length; } public void setData(Object[][] dataarr) {    data=dataarr; } public int getRowCount()  {    return data.length; } public String getColumnName(int col)  {    return columnNames[col]; } public Object getValueAt(int row, int col)  {    return data[row][col]; } public Class getColumnClass(int c)  {    return getValueAt(0, c).getClass(); } public boolean isCellEditable(int row, int col) {    if (col >=1&&col<=7)     {       return false;    }    else    {       return true;    } } public void setValueAt(Object value, int row, int col) {    data[row][col] = value;    fireTableCellUpdated(row, col);    if (col==0&&value.toString().equals("true"))    {       int totalrows=getRowCount();       for (int i=0;i<totalrows;i++ )       {          selectedrow=row;          if (row!=i)          {             data[i][col] =new Boolean(false);          }       }    }    if ((col==9)&&value.toString().equals("true"))    {       data[row][col-1] = new Boolean(false);       fireTableCellUpdated(row, col-1);    }    else    {       if (col==8&&value.toString().equals("true"))       {          data[row][col+1] =new Boolean(false);          fireTableCellUpdated(row, col+1);       }    } } } public void actionPerformed(ActionEvent ae) {    String journeytypestring="Oneway";    String nationalitystring="US Citizen";    String actioncommand=ae.getActionCommand();    if (actioncommand.equals("search"))    {    String informationstring;    String seachstring;    if (validation())    {    if (iradio.isSelected())    {       nationalitystring=iradio.getText();    }    if (nriradio.isSelected())    {    nationalitystring=nriradio.getText();;    }    if (roundtrip.isSelected())    {       journeytypestring="roundtrip";    }    String dmonthpart="";    String rmonthpart="";    String rdaypart="";    String ddaypart="";    int dday=fromdaycombobox.getSelectedIndex()+1;    int dmonth=frommonthcombobox.getSelectedIndex()+1;    if (dday<10)    {       ddaypart="0";    }    if (dmonth<10)    {       dmonthpart="0";    }    int rmonth=tomonthcombobox.getSelectedIndex()+1;    if (rmonth<10)    {       rmonthpart="0";    }    int rday=todaycombobox.getSelectedIndex()+1;    if (rday<10)    {       rdaypart="0";    }    seachstring="#origin="+((String)fromcombobox.getSelectedItem());    seachstring=seachstring+"#destination="+((String)tocombobox.getSelectedItem());    seachstring=seachstring+"#ddate="+((String)fromyearcombobox.getSelectedItem())+dmonthpart+    dmonth+dday    part+dday;  seachstring=seachstring+"#rdate="+((String)toyearcombobox.getSelectedItem())+    rmonthpart+rmonth+rdaypart+rday;    seachstring=seachstring+"#nationality="+nationalitystring;    seachstring=seachstring+"#typeofjurney="+journeytypestring;    informationstring="<message to=\"user10@"+servername+"/airlines\" type=\"chat\">";    informationstring=informationstring+"<body>";    informationstring=informationstring+seachstring;    informationstring=informationstring+"</body></message>";    socketclass.sendXMLToJabber(informationstring); } } if (actioncommand.equals("reset")) {    fromcombobox.setSelectedIndex(0);    tocombobox.setSelectedIndex(0);    todaycombobox.setSelectedIndex(0);    tomonthcombobox.setSelectedIndex(0);    toyearcombobox.setSelectedIndex(0);    fromdaycombobox.setSelectedIndex(0);    frommonthcombobox.setSelectedIndex(0);    Object[][] emptyobject = {};    TableModelReservation emptytable=new TableModelReservation();    emptytable.setData(emptyobject);    t.table.setModel(emptytable);    submitbutton.setEnabled(false); } if (actioncommand.equals("submit")) {    String idstring=(String)idvector.get(selectedrow);    String submitstring="";    submitstring=submitstring+"<message to=\"user10@"+servername+"/airlines\"    type=\"chat\"><body>";    submitstring=submitstring+"#id"+idstring+"#username"+username+"#address="+address+"#city="+city+    "#passportno"+passportno;    submitstring=submitstring+"</body></message>";    socketclass.sendXMLToJabber(submitstring);    Object[][] emptyobject = {};    TableModelReservation emptytable=new TableModelReservation();    emptytable.setData(emptyobject);    t.table.setModel(emptytable);    JOptionPane.showMessageDialog(null,"Data has been submitted, for further details contact airlines    administrator","Dialog box",JOptionPane.PLAIN_MESSAGE);    submitbutton.setEnabled(false); } } /* validation - This method is used to validate user input. Parameters:NA Return Value: boolean */ public boolean validation() {    boolean valid=true;    String validationmessage="";    if ((String)fromcombobox.getSelectedItem()==(String)tocombobox.getSelectedItem())    {       validationmessage="Destination and origin should not be same.";       valid=false;    }    if (Integer.parseInt(spleteddate[1])>(frommonthcombobox.getSelectedIndex()+1))    {       validationmessage=validationmessage+"\n"+"Departure date can not be less than today's date.";       valid=false;    }    else    {       if (Integer.parseInt(spleteddate[1])==(frommonthcombobox.getSelectedIndex()+1))       {          String[] splitday=spleteddate[2].split(" ");          if (Integer.parseInt(splitday[0])>(fromdaycombobox.getSelectedIndex()+1))          {             validationmessage=validationmessage+"\n"+"Departure date can not be less than today's             date.";             valid=false;          }       }    }    if (roundtrip.isSelected())    {       if (Integer.parseInt(spleteddate[1])>(tomonthcombobox.getSelectedIndex()+1))       {       validationmessage=validationmessage+"\n"+"Return date can not be less than today's date.";       valid=false;       }       else       {          if (Integer.parseInt(spleteddate[1])==(tomonthcombobox.getSelectedIndex()+1))          {          String[] splitday=spleteddate[2].split(" ");          if (Integer.parseInt(splitday[0])>(todaycombobox.getSelectedIndex()+1))          {             validationmessage=validationmessage+"\n"+"Return date can not be less than today's date.";             valid=false;          }          }       }    }    if (roundtrip.isSelected())    {       if (Integer.parseInt((String)toyearcombobox.getSelectedItem())<Integer.parseInt((String)       fromyearcombobox.getSelectedItem()))       {          validationmessage=validationmessage+"\n"+"Return date can not be less than Departure date.";          valid=false;       }       else       {          if ((frommonthcombobox.getSelectedIndex())>(tomonthcombobox.getSelectedIndex()))          {             validationmessage=validationmessage+"\n"+"Return date can not be less than Departur date.";             valid=false;          }          else          {             if ((frommonthcombobox.getSelectedIndex())==(tomonthcombobox.getSelectedIndex()))             {                if ((fromdaycombobox.getSelectedIndex())>(todaycombobox.getSelectedIndex()))                {                   validationmessage=validationmessage+"\n"+"Return date can not be less than Departur                   date.";                   valid=false;                }             }          }       }    }    if (!validationmessage.equals(""))    {    JOptionPane.showMessageDialog(null,validationmessage,"Dialog box",JOptionPane.PLAIN_MESSAGE);    }    return valid; } /* addDays - This method is used to fill days into fromdaycombobox. Parameters:fromdaycombobox - Object of JComboBox class. Return Value: NA */ public void addDays(JComboBox fromdaycombobox) {    for (int i=1;i<32 ;i++ )    {       fromdaycombobox.addItem(new Integer(i));    } } /* addMonths - This method is used to fill months into frommonthcombobox Combo. Parameters:frommonthcombobox - Object of JComboBox class Return Value: NA */ public void addMonths(JComboBox frommonthcombobox) {    frommonthcombobox.addItem("January");    frommonthcombobox.addItem("February");    frommonthcombobox.addItem("March");    frommonthcombobox.addItem("April");    frommonthcombobox.addItem("May");    frommonthcombobox.addItem("June");    frommonthcombobox.addItem("July");    frommonthcombobox.addItem("August");    frommonthcombobox.addItem("September");    frommonthcombobox.addItem("October");    frommonthcombobox.addItem("November");    frommonthcombobox.addItem("December"); } /* addYears - This method is used to fill years into fromyearcombobox Combo. Parameters:frommonthcombobox - Object of JComboBox class Return Value: NA */ public void addYears(JComboBox fromyearcombobox) {    Calendar cal = Calendar.getInstance(TimeZone.getDefault());    String DATE_FORMAT = "yyyy-MM-dd HH:mm:ss";    java.text.SimpleDateFormat sdf = new java.text.SimpleDateFormat(DATE_FORMAT);    sdf.setTimeZone(TimeZone.getDefault());     TodayDate=sdf.format(cal.getTime());    System.out.println(TodayDate);    spleteddate=TodayDate.split("-");    fromyearcombobox.addItem(spleteddate[0]);    fromyearcombobox.addItem(new Integer(Integer.parseInt(spleteddate[0])+1)); } } 
end example

Download this listing.

In the above listing, the ReservationStatus.java file creates the user interface by using the ReservationStatus class. The ReservationStatus.java file uses the TableModelReservation class to display the airline schedule in the user interface provided by the Airline Reservation application.

The methods defined in Listing 6-3 are:

  • init(): Creates the user interface for the Airline Reservation application and calls the SocketClass class to establish a connection with the Jabber server.

  • getUserName(): Returns the name of the end user.

  • setTableContent(): Initializes the TableModelReservation class and displays the airline schedule in the user interface provided by the Airline Reservation application.

  • itemStateChanged(): Activates the combo boxes for day, month, and year, if an end user selects the Round trip option.

  • addDays(): Enters number of days in the combo box for the departure date and arrival date.

  • addMonths(): Enters number of months in the combo box for the departure date and arrival date.

  • addYears(): Enters number of years in the combo box for the departure date and arrival date.

  • setValueAt(): Shows the airline schedule received from the Jabber server.

  • actionPerformed(): Acts as an event listener and activates an appropriate class and method based on the action an end user performs.

  • getRowCount(): Returns the total number of records in an airline schedule.

  • validation(): Validates the information specified by the end user.

The ReservationStatus.java file creates the main window of the Airline Reservation application, as shown in Figure 6-3:

click to expand: this figure shows the user interface of the airline reservation application, which contains the from and to combo boxes that represent the starting place and destination place.
Figure 6-3: User Interface of the Airline Reservation Application




Developing Applications Using Jabber
Developing Applications Using Jabber
ISBN: N/A
EAN: N/A
Year: 2004
Pages: 68

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net