booking system

  1. /*
  2.  * SelectPanel.java
  3.  *
  4.  * Created on 3 novembre 2004, 13:42
  5.  */
  6. package reservation.system.panels;
  7. import reservation.system.functions.Functions;
  8. import reservation.system.Profile;
  9. import reservation.system.Flight;
  10. import reservation.system.Person;
  11. import reservation.system.Pos;
  12. import reservation.CustomDialog;
  13.  
  14. import javax.swing.*;
  15. import javax.swing.border.*;
  16. import javax.swing.table.*;
  17. import java.awt.event.*;
  18. import java.util.Vector;
  19. import java.awt.Dimension;
  20. import java.util.StringTokenizer;
  21.  
  22. /**
  23.  * This class hold Flight structure. This object allows to see the flight present in the database.
  24.  * It use a GUI that contains a form with the several field to fill.
  25.  * @author Texier Mathieu and Frederic Bidon
  26.  */
  27. public class FlightsPanel extends Panels {
  28.    
  29.     /** Creates new form FlightsPanel */
  30.     public FlightsPanel () {
  31.         jScrollPane = new JScrollPane ();
  32.         flightTable = new JTable ();
  33.        
  34.         jScrollPane.setBorder (new SoftBevelBorder (BevelBorder.RAISED));
  35.         flightTable.setRowSelectionAllowed (false);
  36.         jScrollPane.setViewportView (flightTable);
  37.        
  38.         add (jScrollPane);
  39.     }
  40.    
  41.     /**
  42.      * Causes this container to lay out its components.
  43.      */
  44.     public void doLayout () {
  45.         jScrollPane.setBounds (20, 20, 500, 120);
  46.         flightTable.setBounds (20, 20, 500, 120);
  47.     }
  48.    
  49.     /**
  50.      * Set the size of the panel
  51.      * @return an instance of Dimension that represents the minimum size of this container.
  52.      */
  53.     public Dimension getMinimumSize () {
  54.         return new Dimension (550,160);
  55.     }
  56.    
  57.     /**
  58.      * Set the size of the panel
  59.      * @return an instance of Dimension that represents the preferred size of this container.
  60.      */
  61.     public Dimension getPreferredSize () {
  62.         return new Dimension (550,160);
  63.     }
  64.    
  65.     /**
  66.      * Initialize the number of the field and fill them with default values.
  67.      * Dispaly the label of the Window.
  68.      */
  69.     public void init () {
  70.         try {
  71.             String[] listFlight = fs.getFlightList ();
  72.        
  73.         int size = listFlight.length;
  74.         String listData[][] = new String[size][4];
  75.         String title[] = {"Name", "Rows", "Row length"};
  76.            
  77.         for(int i = 0; i < size; i++) {
  78.             Flight flight = fs.selectFlight (listFlight[i]);
  79.             listData[i][0] = flight.getFlightName ();
  80.             listData[i][1] = Integer.toString(flight.getDimension ().getRow ());
  81.             listData[i][2] = Integer.toString(flight.getDimension ().getCol ());
  82.         }
  83.         flightTable.setModel (new DefaultTableModel (listData,title));
  84.         } catch (Exception e) {CustomDialog.alert(e);}
  85.     }
  86.    
  87.     /**
  88.      * Proceed the execution of the action
  89.      * @return the result of the request.
  90.      * @param unUsed not used
  91.      * @throws Exception if the command is not executed.
  92.      */
  93.     public String execute (String[] unUsed) throws Exception {
  94.         return "";
  95.     }
  96.    
  97.     private JTable flightTable;
  98.     private JScrollPane jScrollPane;
  99. }
  100.  

contact - link to this site