Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.awt.EventQueue;
- import javax.swing.JFrame;
- import java.awt.Color;
- import javax.swing.ImageIcon;
- import javax.swing.JPanel;
- import java.awt.CardLayout;
- import javax.swing.JButton;
- import java.awt.event.ActionListener;
- import java.awt.event.ActionEvent;
- import javax.swing.SwingConstants;
- import java.awt.Font;
- import javax.swing.BorderFactory;
- import javax.swing.JTextArea;
- import javax.swing.JLabel;
- import javax.swing.JCheckBox;
- import javax.swing.JTextField;
- import javax.swing.JTable;
- import javax.swing.table.DefaultTableModel;
- import javax.swing.border.LineBorder;
- import javax.swing.border.MatteBorder;
- import javax.swing.BoxLayout;
- import javax.swing.JComboBox;
- import javax.swing.DefaultComboBoxModel;
- import java.awt.GridLayout;
- public class ChairyPick{
- private JFrame frame;
- private JTextField txtNumpeople;
- private JTextField txtChild;
- private int selectedFlight = 0; //flight identifier
- private String flight1 = "San Francisco to New York City";
- private String flight2 = "San Francisco to Miami";
- private String flight3 = "San Francisco to Las Vegas";
- private JTable table;
- private JTable table_1;
- private JTable order;
- private JTextField txtFirstName;
- private JTextField txtLastName;
- private JTextField txtCreditCardNumber;
- private JTextField txtStreetAddress;
- private JTextField txtCvc;
- private JTextField txtCity;
- private JTextField txtState;
- private JTextField txtZipCode;
- private JCheckBox chckbxEconomyClass;
- private JCheckBox chckbxHandicapped;
- UserPreferences pref;
- /**
- * Launch the application.
- */
- public static void main(String[] args) {
- EventQueue.invokeLater(new Runnable() {
- public void run() {
- try {
- ChairyPick window = new ChairyPick();
- window.frame.setVisible(true);
- } catch (Exception e) {
- e.printStackTrace();
- }
- }
- });
- }
- /**
- * Create the application.
- */
- public ChairyPick() {
- initialize();
- }
- /**
- * Initialize the contents of the frame.
- */
- private void initialize() {
- frame = new JFrame();
- frame.setBackground(Color.WHITE);
- frame.setResizable(false);
- frame.getContentPane().setBackground(new Color(255, 255, 255));
- frame.getContentPane().setLayout(new CardLayout(0, 0));
- final JPanel panelMenu = new JPanel();
- panelMenu.setBackground(Color.WHITE);
- frame.getContentPane().add(panelMenu, "name_1446238410875293000");
- panelMenu.setLayout(null);
- final JPanel panelPreferences = new JPanel();
- panelPreferences.setBackground(Color.WHITE);
- frame.getContentPane().add(panelPreferences, "name_1446238417539194000");
- panelPreferences.setLayout(null);
- final JPanel panelChart = new JPanel();
- panelMenu.setBackground(Color.WHITE);
- frame.getContentPane().add(panelChart, "name_1446238420814244000");
- panelChart.setLayout(null);
- //frame = new JFrame();
- //frame.setBounds(100, 100, 450, 640);
- //frame.setBackground(Color.WHITE);
- //frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
- //frame.getContentPane().setLayout(null);
- //panelChart.add(frame);
- JPanel pnlFir1 = new JPanel(); //panel for the 1st first-class set
- panelChart.add(pnlFir1);
- pnlFir1.setBounds(27, 27, 93, 85);
- pnlFir1.setLayout(new GridLayout(2, 2, 10, 10));
- JPanel pnlFir2 = new JPanel();
- panelChart.add(pnlFir2);
- pnlFir2.setBounds(177, 27, 93, 85);
- pnlFir2.setLayout(new GridLayout(2, 2, 10, 10));
- JPanel pnlFir3 = new JPanel();
- panelChart.add(pnlFir3);
- pnlFir3.setBounds(322, 27, 93, 85);
- pnlFir3.setLayout(new GridLayout(2, 2, 10, 10));
- JPanel pnlBus1 = new JPanel();
- panelChart.add(pnlBus1);
- pnlBus1.setBounds(27, 135, 93, 151);
- pnlBus1.setLayout(new GridLayout(6, 2, 5, 5));
- JPanel pnlBus2 = new JPanel();
- panelChart.add(pnlBus2);
- pnlBus2.setBounds(177, 135, 93, 151);
- pnlBus2.setLayout(new GridLayout(6, 2, 5, 5));
- JPanel pnlBus3 = new JPanel();
- panelChart.add(pnlBus3);
- pnlBus3.setBounds(322, 135, 93, 151);
- pnlBus3.setLayout(new GridLayout(6, 2, 5, 5));
- JPanel pnlEco1 = new JPanel();
- panelChart.add(pnlEco1);
- pnlEco1.setBounds(27, 309, 93, 261);
- pnlEco1.setLayout(new GridLayout(8, 3, 5, 5));
- JPanel pnlEco2 = new JPanel();
- panelChart.add(pnlEco2);
- pnlEco2.setBounds(177, 309, 93, 261);
- pnlEco2.setLayout(new GridLayout(8, 3, 5, 5));
- JPanel pnlEco3 = new JPanel();
- panelChart.add(pnlEco3);
- pnlEco3.setBounds(322, 309, 93, 261);
- pnlEco3.setLayout(new GridLayout(8, 3, 5, 5));
- //*****************************************Flight Selection Menu******************************************
- JTextArea txtrAvailableFlights = new JTextArea();
- txtrAvailableFlights.setEditable(false);
- txtrAvailableFlights.setFont(new Font("Orator Std", Font.PLAIN, 25));
- txtrAvailableFlights.setText("Available Flights");
- txtrAvailableFlights.setBounds(94, 32, 263, 42);
- panelMenu.add(txtrAvailableFlights);
- JButton flight1 = new JButton(new ImageIcon(ChairyPick.class.getResource("/img/flight-1.png")));
- flight1.addActionListener(new ActionListener() {
- public void actionPerformed(ActionEvent e) {
- selectedFlight = 1;
- panelMenu.setVisible(false);
- panelPreferences.setVisible(true);
- }
- });
- flight1.setBounds(30, 97, 390, 127);
- panelMenu.add(flight1);
- JButton flight2 = new JButton("flight2");
- flight2.addActionListener(new ActionListener() {
- public void actionPerformed(ActionEvent e) {
- selectedFlight = 2;
- panelMenu.setVisible(false);
- panelPreferences.setVisible(true);
- }
- });
- flight2.setIcon(new ImageIcon(ChairyPick.class.getResource("/img/flight-2.png")));
- flight2.setBounds(30, 266, 390, 127);
- panelMenu.add(flight2);
- JButton flight3 = new JButton("flight3");
- flight3.addActionListener(new ActionListener() {
- public void actionPerformed(ActionEvent e) {
- selectedFlight = 3;
- panelMenu.setVisible(false);
- panelPreferences.setVisible(true);
- }
- });
- flight3.setIcon(new ImageIcon(ChairyPick.class.getResource("/img/flight-3.png")));
- flight3.setBounds(30, 433, 390, 127);
- frame.setBounds(100, 100, 450, 640);
- panelMenu.add(flight3);
- //*****************************************User Preferences******************************************
- JLabel lblNumberOfPeople = new JLabel("Number of People:");
- lblNumberOfPeople.setFont(new Font("Orator Std", Font.PLAIN, 18));
- lblNumberOfPeople.setBounds(25, 131, 194, 40);
- panelPreferences.add(lblNumberOfPeople);
- JLabel lblChildren = new JLabel("How many are children?");
- lblChildren.setBounds(25, 197, 250, 40);
- lblChildren.setFont(new Font("Orator Std", Font.PLAIN, 18));
- panelPreferences.add(lblChildren);
- JCheckBox chckbxBusinessClass = new JCheckBox("Business Class");
- chckbxBusinessClass.setFont(new Font("Orator Std", Font.PLAIN, 16));
- chckbxBusinessClass.setBounds(25, 281, 182, 23);
- panelPreferences.add(chckbxBusinessClass);
- chckbxEconomyClass = new JCheckBox("Economy Class");
- chckbxEconomyClass.setFont(new Font("Orator Std", Font.PLAIN, 16));
- chckbxEconomyClass.setBounds(219, 270, 194, 46);
- panelPreferences.add(chckbxEconomyClass);
- txtNumpeople = new JTextField();
- txtNumpeople.setBounds(231, 133, 80, 28);
- panelPreferences.add(txtNumpeople);
- txtNumpeople.setColumns(10);
- txtChild = new JTextField();
- txtChild.setBounds(288, 199, 61, 28);
- panelPreferences.add(txtChild);
- txtChild.setColumns(1);
- chckbxHandicapped = new JCheckBox("Handicapped");
- chckbxHandicapped.setFont(new Font("Orator Std", Font.PLAIN, 16));
- chckbxHandicapped.setBounds(131, 345, 205, 37);
- panelPreferences.add(chckbxHandicapped);
- JLabel lblSeatPreferences = new JLabel("Seat Preferences");
- lblSeatPreferences.setFont(new Font("Orator Std", Font.PLAIN, 24));
- lblSeatPreferences.setHorizontalAlignment(SwingConstants.CENTER);
- lblSeatPreferences.setBounds(95, 40, 279, 40);
- panelPreferences.add(lblSeatPreferences);
- JButton btnSearch = new JButton("Search");
- btnSearch.addActionListener(new ActionListener() {
- public void actionPerformed(ActionEvent e) {
- int people = Integer.parseInt(txtNumpeople.getText());
- int child = Integer.parseInt(txtChild.getText());
- boolean eco = chckbxEconomyClass.isEnabled();
- boolean handicap = chckbxHandicapped.isEnabled();
- UserPreferences pref = new UserPreferences(people,child,eco,handicap);
- }
- });
- btnSearch.setIcon(new ImageIcon(ChairyPick.class.getResource("/img/search.png")));
- btnSearch.setBounds(62, 453, 303, 70);
- panelPreferences.add(btnSearch);
- btnSearch.addActionListener(new ActionListener() {
- public void actionPerformed(ActionEvent e){
- panelChart.setVisible(true);
- panelPreferences.setVisible(false);
- }
- });
- JButton btnBack = new JButton("");
- btnBack.addActionListener(new ActionListener() {
- public void actionPerformed(ActionEvent e) {
- panelMenu.setVisible(true);
- panelPreferences.setVisible(false);
- }
- });
- btnBack.setBorder(BorderFactory.createEmptyBorder());
- btnBack.setIcon(new ImageIcon(ChairyPick.class.getResource("/img/back.png")));
- btnBack.setBounds(6, 25, 80, 56);
- panelPreferences.add(btnBack);
- //*****************************************Plane Chart******************************************
- Color ecoColor = new Color(98, 148, 229); //blue
- Color busColor = new Color(125, 69, 216); //purple
- //panelChart.add(pnlFir1);
- String[]lblFir1 = {"FA1", "FA2", "FB1", "FB2"};
- JButton[] seats = new JButton[lblFir1.length];
- for(int i = 0; i < seats.length; i++){
- seats[i] = new JButton(lblFir1[i]);
- //seats[i].setFont(new Font("Arial", Font.PLAIN, 4));
- seats[i].setBackground(new Color(255, 195, 0));//yellow
- seats[i].setOpaque(true);
- seats[i].setBorder(null);
- seats[i].setBorderPainted(false);
- pnlFir1.add(seats[i]);
- panelChart.add(pnlFir1);
- }
- //panelChart.add(pnlFir2);
- String[]lblFir2 = {"FA3", "FA4", "FB3", "FB4"};
- JButton[] seats1 = new JButton[lblFir2.length];
- for(int i = 0; i < seats1.length; i++){
- seats1[i] = new JButton(lblFir2[i]);
- seats1[i].setBackground(new Color(255, 195, 0));//yellow
- seats1[i].setOpaque(true);
- seats1[i].setBorder(null);
- seats1[i].setBorderPainted(false);
- pnlFir2.add(seats1[i]);
- panelChart.add(pnlFir2);
- }
- String[]lblFir3 = {"FA5", "FA6", "FB5", "FB6"};
- JButton[] seats2 = new JButton[lblFir2.length];
- for(int i = 0; i < seats2.length; i++){
- seats2[i] = new JButton(lblFir2[i]);
- seats2[i].setBackground(new Color(255, 195, 0));//yellow
- seats2[i].setOpaque(true);
- seats2[i].setBorder(null);
- seats2[i].setBorderPainted(false);
- pnlFir3.add(seats2[i]);
- }
- String[]lblBus1 = {"BA1", "BA2","BB1", "BB2", "BC1","BC2", "BD1", "BD2","BE1","BE2","BF1","BF2"};
- JButton[] seats3 = new JButton[lblBus1.length];
- for(int i = 0; i < seats3.length; i++){
- seats3[i] = new JButton(lblBus1[i]);
- seats3[i].setBackground(new Color(125, 69, 216));//purple
- seats3[i].setOpaque(true);
- seats3[i].setBorder(null);
- seats3[i].setBorderPainted(false);
- pnlBus1.add(seats3[i]);
- }
- String[]lblBus2 = {"BA3", "BA4","BB3", "BB4", "BC3","BC4", "BD3", "BD4","BE3","BE4","BF3","BF4"};
- JButton[] seats4 = new JButton[lblBus2.length];
- for(int i = 0; i < seats4.length; i++){
- seats4[i] = new JButton(lblBus2[i]);
- seats4[i].setBackground(busColor);//purple
- seats4[i].setOpaque(true);
- seats4[i].setBorder(null);
- seats4[i].setBorderPainted(false);
- pnlBus2.add(seats4[i]);
- }
- String[]lblBus3 = {"BA5", "BA6","BB5", "BB6", "BC5","BC6", "BD5", "BD6","BE5","BE6","BF5","BF6"};
- JButton[] seats5 = new JButton[lblBus3.length];
- for(int i = 0; i < seats5.length; i++){
- seats5[i] = new JButton(lblBus3[i]);
- seats5[i].setBackground(busColor);//purple
- seats5[i].setOpaque(true);
- seats5[i].setBorder(null);
- seats5[i].setBorderPainted(false);
- pnlBus3.add(seats5[i]);
- }
- String[]lblEco1 = {"EA1", "EA2","EA3", "EB1", "EB2","EB3", "EC1",
- "EC2","EC3","ED1","ED2","ED3","EE1","EE2","EE3",
- "EF1","EF2","EF3","EG1","EG2","EG3","EH1","EH2","EH3"};
- JButton[] seats6 = new JButton[lblEco1.length];
- for(int i = 0; i < seats6.length; i++){
- seats6[i] = new JButton(lblEco1[i]);
- seats6[i].setBackground(ecoColor);//blue
- seats6[i].setOpaque(true);
- seats6[i].setBorder(null);
- seats6[i].setBorderPainted(false);
- pnlEco1.add(seats6[i]);
- }
- String[]lblEco2 = {"EA4", "EA4","EA6", "EB4", "EB5","EB6", "EC4",
- "EC5","EC6","ED4","ED5","ED6","EE4","EE5","EE6",
- "EF4","EF5","EF6","EG4","EG5","EG6","EH4","EH5","EH6"};
- JButton[] seats7 = new JButton[lblEco2.length];
- for(int i = 0; i < seats7.length; i++){
- seats7[i] = new JButton(lblEco2[i]);
- seats7[i].setBackground(ecoColor);//blue
- seats7[i].setOpaque(true);
- seats7[i].setBorder(null);
- seats7[i].setBorderPainted(false);
- pnlEco2.add(seats7[i]);
- }
- String[]lblEco3 = {"EA4", "EA4","EA6", "EB4", "EB5","EB6", "EC4",
- "EC5","EC6","ED4","ED5","ED6","EE4","EE5","EE6",
- "EF4","EF5","EF6","EG4","EG5","EG6","EH4","EH5","EH6"};
- JButton[] seats8 = new JButton[lblEco3.length];
- for(int i = 0; i < seats8.length; i++){
- seats8[i] = new JButton(lblEco2[i]);
- seats8[i].setBackground(ecoColor);//blue
- seats8[i].setOpaque(true);
- seats8[i].setBorder(null);
- seats8[i].setBorderPainted(false);
- pnlEco3.add(seats8[i]);
- }
- //*****************************************Order Checkout******************************************
- JPanel panelCheckout = new JPanel();
- panelCheckout.setBackground(Color.WHITE);
- frame.getContentPane().add(panelCheckout, "name_1446238423153284000");
- panelCheckout.setLayout(null);
- String rowData[][] = { { "Row1-Column1", "Row1-Column2", "Row1-Column3" },
- { "Row2-Column1", "Row2-Column2", "Row2-Column3" } };
- String columnNames[] = { "Column One", "Column Two", "Column Three" };
- order = new JTable(rowData, columnNames);
- order.setModel(new DefaultTableModel(
- new Object[][] {
- {"Item Description", "Quantity", "Price"},
- {"SFO to NYC Economy x2", "2", "$400"},
- },
- new String[] {
- "Column One", "Column Two", "Column Three"
- }
- ));
- order.setBorder(new LineBorder(new Color(0, 0, 0)));
- order.setBounds(37, 86, 400, 45);
- panelCheckout.add(order);
- JLabel lblPaymentOption = new JLabel("Payment Option:");
- lblPaymentOption.setBounds(37, 226, 132, 45);
- panelCheckout.add(lblPaymentOption);
- txtFirstName = new JTextField();
- txtFirstName.setText("First Name");
- txtFirstName.setBounds(27, 290, 173, 28);
- panelCheckout.add(txtFirstName);
- txtFirstName.setColumns(10);
- txtLastName = new JTextField();
- txtLastName.setText("Last Name");
- txtLastName.setBounds(212, 290, 172, 28);
- panelCheckout.add(txtLastName);
- txtLastName.setColumns(10);
- txtCreditCardNumber = new JTextField();
- txtCreditCardNumber.setText("Credit Card Number");
- txtCreditCardNumber.setBounds(27, 352, 275, 28);
- panelCheckout.add(txtCreditCardNumber);
- txtCreditCardNumber.setColumns(10);
- JComboBox comboBox = new JComboBox();
- comboBox.setModel(new DefaultComboBoxModel(new String[] {"Visa", "MasterCard", "American Express", "Discover"}));
- comboBox.setBounds(202, 236, 139, 27);
- panelCheckout.add(comboBox);
- JLabel lblExpirationDate = new JLabel("Expiration Date:");
- lblExpirationDate.setBounds(27, 402, 132, 28);
- panelCheckout.add(lblExpirationDate);
- JComboBox comboBox_1 = new JComboBox();
- comboBox_1.setModel(new DefaultComboBoxModel(new String[] {"Month", "01", "02", "03", "04", "05", "06", "07", "08", "09", "10", "11", "12"}));
- comboBox_1.setBounds(161, 404, 112, 27);
- panelCheckout.add(comboBox_1);
- JComboBox comboBox_2 = new JComboBox();
- comboBox_2.setModel(new DefaultComboBoxModel(new String[] {"Year", "2015", "2016", "2017", "2018", "2019", "2020", "2021", "2022", "2023", "2024"}));
- comboBox_2.setBounds(297, 404, 85, 27);
- panelCheckout.add(comboBox_2);
- JLabel lblBillingAddress = new JLabel("Billing Address:");
- lblBillingAddress.setBounds(27, 442, 112, 28);
- panelCheckout.add(lblBillingAddress);
- txtStreetAddress = new JTextField();
- txtStreetAddress.setText("Street Address");
- txtStreetAddress.setBounds(161, 442, 220, 28);
- panelCheckout.add(txtStreetAddress);
- txtStreetAddress.setColumns(10);
- txtCvc = new JTextField();
- txtCvc.setText("CVC");
- txtCvc.setBounds(325, 352, 59, 28);
- panelCheckout.add(txtCvc);
- txtCvc.setColumns(10);
- txtCity = new JTextField();
- txtCity.setText("City");
- txtCity.setBounds(27, 494, 134, 28);
- panelCheckout.add(txtCity);
- txtCity.setColumns(10);
- txtState = new JTextField();
- txtState.setText("State");
- txtState.setBounds(171, 494, 79, 28);
- panelCheckout.add(txtState);
- txtState.setColumns(10);
- txtZipCode = new JTextField();
- txtZipCode.setText("Zip Code");
- txtZipCode.setBounds(262, 494, 122, 28);
- panelCheckout.add(txtZipCode);
- txtZipCode.setColumns(10);
- JButton button = new JButton("");
- button.setIcon(new ImageIcon(ChairyPick.class.getResource("/img/pay-button.png")));
- button.setBounds(151, 556, 122, 36);
- panelCheckout.add(button);
- JLabel lblCheckout = new JLabel("Checkout");
- lblCheckout.setFont(new Font("Orator Std", Font.PLAIN, 24));
- lblCheckout.setBounds(161, 36, 122, 28);
- panelCheckout.add(lblCheckout);
- JPanel panelFlights = new JPanel();
- frame.getContentPane().add(panelFlights, "name_1446238425531267000");
- JPanel panelTicket = new JPanel();
- frame.getContentPane().add(panelTicket, "name_1446238611138342000");
- frame.setBounds(100, 100, 450, 640);
- frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
- }
- private void initializeChart(){
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment