Exemplo n.º 1
0
 public static void main(String[] args) {
   // TODO 自动生成的方法存根
   Show.inFrame(new Table(), 200, 200);
 }
Exemplo n.º 2
0
  /**
   * This is the constructor for objects of the class ChangeReservationDialog
   *
   * @param markedSeats A collection of the seats marked in the room overview
   * @param show The show chosen in the result table
   * @param customerID The phonenumber of the customer
   * @param frame The frame the dialog was called from
   */
  public ChangeReservationDialog(
      ArrayList<Seat> markedSeats, Show show, int customerID, MainFrame frame) {
    super("Reservation");

    Container contentPane = getContentPane();
    contentPane.setLayout(new BorderLayout());

    Border standart = BorderFactory.createEmptyBorder(5, 5, 5, 5);
    JPanel north = new JPanel();
    north.setBorder(standart);
    contentPane.add(north, BorderLayout.NORTH);

    JLabel topText =
        new JLabel(
            "Du forsøger at ændre en reservation til en med følgende "
                + markedSeats.size()
                + " sæder til: "
                + show.toString());
    north.add(topText);

    JPanel center = new JPanel();
    center.setLayout(new FlowLayout());
    center.setBorder(standart);
    contentPane.add(center, BorderLayout.CENTER);
    String seatString = "<html>";
    for (Seat s : markedSeats) {
      seatString += s.toString() + "<br>";
    }
    seatString += "</html>";
    JLabel seatText = new JLabel(seatString);
    seatText.setBackground(Color.WHITE);
    center.add(seatText);

    JPanel south = new JPanel();
    south.setLayout(new BorderLayout());
    south.setBorder(standart);
    contentPane.add(south, BorderLayout.SOUTH);

    JPanel phoneSection = new JPanel();
    JLabel costumerText = new JLabel("Kundens telefonnummer: " + customerID);
    phoneSection.add(costumerText);

    JPanel buttons = new JPanel();
    JButton cancel = new JButton("Annuller");
    cancel.addActionListener(
        new ActionListener() {
          @Override
          public void actionPerformed(ActionEvent e) {
            dispose();
          }
        });
    JButton reserve = new JButton("Ændre");
    reserve.addActionListener(
        new ActionListener() {
          @Override
          public void actionPerformed(ActionEvent e) {

            String number = "" + customerID;

            if (number.length() == 8) {
              Database.deleteReservations(show, customerID);
              for (Seat s : markedSeats) {
                Database.makeReservation(show, new Customer(Integer.parseInt(number)), s);
              }

              ChangeReservationDialog.this.dispose();
              frame.reset();
            }
          }
        });
    buttons.add(cancel);
    buttons.add(reserve);

    south.add(buttons, BorderLayout.SOUTH);

    setDefaultCloseOperation(JFrame.DISPOSE_ON_CLOSE);
    pack();
    setVisible(true);
  }
Exemplo n.º 3
0
 public static void main(String args[]) {
   Show.inFrame(new Menus(), 300, 200);
 }