📄 reservepanel.java
字号:
/* * ReservePanel.java * The package panels contains the different class executing the different windows of each function of the FlightSystem Reservation. */package reservation.system.panels;import reservation.system.functions.Reserve;import reservation.CustomDialog;import javax.swing.*;import java.awt.event.*;import java.awt.Dimension;/** * This class hold Reserve structure. This object allows to reserve to one flight one or many persons by calling the method <CODE>reserve</CODE> in {@link reservation.system.FlightSystem}. * It use a GUI that contains a form with the several field to fill. * @author Texier Mathieu and Frederic Bidon */public class ReservePanel extends Panels { /** Creates new form ReservePanel */ public ReservePanel () { action = new Reserve (); selectLabel = new JLabel (); flightSelect = new JComboBox (); passengerLabel = new JLabel (); nameSelect = new JComboBox (); addButton = new JButton (); selectLabel.setText ("Select"); add (selectLabel); flightSelect.setMaximumSize (new Dimension (100, 20)); add (flightSelect); passengerLabel.setText ("Passenger"); add (passengerLabel); nameSelect.setEditable (true); add (nameSelect); addButton.setText ("Add"); add (addButton); addButton.addActionListener (new ActionListener () { public void actionPerformed (ActionEvent evt) { nameSelect.addItem ( nameSelect.getSelectedItem ()); nameSelect.getEditor ().setItem (""); } }); } /** * Initialize the number of the field and fill them with default values. * Dispaly the label of the Window. */ public void init () { try { String [] retValue = fs.getFlightList (); if (retValue != null) { for (int i=0;i< retValue.length;i++) { flightSelect.addItem (retValue[i]); } } } catch (Exception e) { CustomDialog.alert (e); } } /** * Causes this container to lay out its components. */ public void doLayout () { selectLabel.setBounds (20, 20, 40, 20); flightSelect.setBounds (110, 20, 140, 20); passengerLabel.setBounds (20, 60, 80, 20); nameSelect.setBounds (110, 60, 70, 20); addButton.setBounds (190, 60, 60, 20); } /** * Set the size of the panel * @return an instance of Dimension that represents the minimum size of this container. */ public Dimension getMinimumSize () { return new Dimension (300,100); } /** * Set the size of the panel * @return an instance of Dimension that represents the preferred size of this container. */ public Dimension getPreferredSize () { return new Dimension (300,100); } /** * Proceed the execution of the action * @return the result of the request. * @param unUsed not used * @throws Exception if the command is not executed. */ public String execute (String[] unUsed) throws Exception { int itemNumber = nameSelect.getItemCount (); String arg[] = new String[itemNumber+1]; arg[0] = (String) flightSelect.getSelectedItem (); for (int i=0;i<itemNumber;i++) { arg[i+1] = (String) nameSelect.getItemAt (i); } return action.execute (arg); } private JButton addButton; private JComboBox flightSelect; private JComboBox nameSelect; private JLabel passengerLabel; private JLabel selectLabel;}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -