Exemple #1
0
  public aboutsw() {
    b1 = new JButton();
    l1 = new JLabel();
    l2 = new JLabel();
    l3 = new JLabel();
    l4 = new JLabel();
    l5 = new JLabel();

    getContentPane().setLayout(null);
    setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
    setResizable(false);
    setUndecorated(true);

    getAccessibleContext().setAccessibleName("About");

    b1.setText("Close");
    getContentPane().add(b1);
    b1.setBounds(250, 180, 80, 25);
    b1.addActionListener(new closeListener());

    l1.setFont(new Font("Microsoft Sans Serif", 0, 20));
    l1.setForeground(new java.awt.Color(153, 153, 255));
    l1.setText("Plateform  : ");
    getContentPane().add(l1);
    l1.setBounds(50, 70, 120, 20);

    l2.setText("Gift Sales & Management System");
    l2.setFont(new Font("Century Schoolbook", 1, 16));
    l2.setForeground(new java.awt.Color(255, 51, 51));
    getContentPane().add(l2);
    l2.setBounds(34, 10, 410, 30);

    l3.setForeground(new Color(0, 0, 153));
    l3.setText("Windows 98 / 2000 / XP / Vista / 7");
    getContentPane().add(l3);
    l3.setBounds(100, 95, 200, 20);

    l4.setText("Powered by :");
    l4.setFont(new Font("Microsoft Sans Serif", 0, 18));
    l4.setForeground(new java.awt.Color(153, 153, 255));
    getContentPane().add(l4);
    l4.setBounds(50, 120, 130, 20);

    l5.setText("Amit Kumar Sah");
    l5.setFont(new Font("Microsoft Sans Serif", 0, 18));
    getContentPane().add(l5);
    l5.setBounds(100, 150, 190, 20);
    l5.setForeground(new Color(100, 100, 51));

    Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
    setBounds((screenSize.width - 400) / 2, (screenSize.height - 220) / 2, 450, 240);

    setVisible(true);
  }
Exemple #2
0
  /**
   * Sets up the airplane seating GUI. Adds in all the buttons, keeping a space for the aisle.
   *
   * @precondition the button is still clickable
   */
  public void run() {

    Airplane.aLock.lock();

    JFrame manualreservation = new JFrame();
    manualreservation.setTitle("Airplane Reservation System");
    manualreservation.setPreferredSize(new Dimension(500, 500));
    JPanel panel = new JPanel(new GridLayout(50, 5));
    JPanel container = new JPanel();

    for (int rows = 0; rows < 50; rows++) {
      for (int columns = 0; columns < 5; columns++) {
        if (columns == 2) {
          JButton empty = new JButton("");
          empty.setEnabled(false);
          panel.add(empty);

        } else {
          JButton button = new JButton();

          if (columns > 2) {
            button.setText((rows) + "," + (columns - 1));
            Airplane.buttons.add(button);
          } else {
            button.setText((rows) + "," + (columns));
            Airplane.buttons.add(button);
          }

          /**
           * Attached an Action Listener to every button. Sets the clicked button to un-clickable
           * and updates the button ArrayList and seating array.
           */
          button.addActionListener(
              new ActionListener() {

                public void actionPerformed(ActionEvent seatselected) {

                  JButton buttonclicked = (JButton) seatselected.getSource();
                  String[] temp = buttonclicked.getText().split(",");
                  int[] location = new int[temp.length];
                  for (int i = 0; i < temp.length; i++) {
                    location[i] = Integer.parseInt(temp[i]);
                  }
                  int loc = location[0] * 4 + location[1];

                  airplane.setSeat(location[0], location[1], 3);
                  buttonclicked.setText("3");
                  buttonclicked.setEnabled(false);
                  Airplane.buttons.add(buttonclicked);
                  Airplane.buttons.get(loc).setEnabled(false);
                  Airplane.buttons.get(loc).setText("3");
                }
              });
          panel.add(button);
        }
      }
    }

    container.add(panel);
    JScrollPane jsp = new JScrollPane(container);

    manualreservation.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    manualreservation.add(jsp);
    manualreservation.pack();
    manualreservation.setVisible(true);

    Airplane.aLock.unlock();
  }