-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathConfirmPanel.java
More file actions
154 lines (126 loc) · 5.56 KB
/
ConfirmPanel.java
File metadata and controls
154 lines (126 loc) · 5.56 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
import javax.swing.*;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
public class ConfirmPanel extends JPanel {
private Color Red = new Color(139, 0, 0);
private Color Yellow = new Color(255, 248, 191);
private Color Orange = new Color(244, 138, 104);
private MovieTheatreApp app;
private Movie movie;
private Location theatre;
private Showtime showtime;
private Seat seat;
private JLabel movieName;
private JLabel theatreName;
private JLabel seatName;
private JLabel showtimeName;
private JLabel costName;
private JPanel clientPanel;
private GridBagConstraints gbc;
public ConfirmPanel(MovieTheatreApp app, UserDatabaseManager userDBM, MovieTheatreController movieTC) {
this.app = app;
this.setLayout(new BorderLayout());
this.setBackground(Yellow);
JButton confirmButton = new JButton("Confirm");
confirmButton.setForeground(Red);
confirmButton.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e)
{
// SHOULD SWITCH TO PAYMENT PANEL
if (app.getCurrentUser() == 1) {// if a RU is currently using our app
PaymentRUPanel pay = app.getPaymentRUPanel();
pay.displaySavedPayments(app.getRU());
app.switchToPaymentRU();
}
else if (app.getCurrentUser() == 0){ // if its a guest currently using it
app.switchToPayment();
}
}
});
JPanel centerPanel = new JPanel();
System.out.println("IN CONFIRM PANEL");
Movie movie = app.getMovie(); // Assuming app.getMovie() returns a Movie object
Location theatre = app.getTheatre(); // Assuming app.getTheatre() returns a Theatre object
clientPanel = new JPanel();
clientPanel.setLayout(new GridBagLayout());
gbc = new GridBagConstraints();
gbc.fill = GridBagConstraints.HORIZONTAL;
gbc.insets = new Insets(5, 5, 5, 5);
clientPanel.setBackground(Yellow);
this.add(clientPanel, BorderLayout.CENTER);
JPanel confirmPanel = new JPanel();
confirmPanel.setLayout(new FlowLayout(FlowLayout.CENTER)); // Centering the button
confirmPanel.setBackground(Yellow);
this.add(Box.createVerticalStrut(20)); // Adds vertical space between buttons
JButton backButton = new JButton("Back");
backButton.setForeground(Red);
confirmPanel.add(backButton);
confirmPanel.add(confirmButton);
backButton.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
movieName.setText("");
theatreName.setText("");
showtimeName.setText("");
seatName.setText("");
int row = 0;
addComponent(clientPanel, movieName, 1, row++, gbc);
addComponent(clientPanel, theatreName, 1, row++, gbc);
addComponent(clientPanel, seatName, 1, row++, gbc);
addComponent(clientPanel, showtimeName, 1, row++, gbc);
app.switchToMovieList();
}
});
this.add(confirmPanel, BorderLayout.SOUTH);
}
public void getInfo() {
clientPanel.removeAll();
this.seat = app.getSelectedSeat();
this.movie = app.getMovie();
this.theatre = app.getTheatre();
this.showtime = app.getSelectedShowtime();
System.out.println("IN GET INFO");
System.out.println(movie.getTitle());
System.out.println(theatre.getName());
movieName = new JLabel(movie.getTitle());
movieName.setForeground(Red);
theatreName = new JLabel(theatre.getName());
theatreName.setForeground(Red);
seatName = new JLabel(seat.toString());
seatName.setForeground(Red);
String showtimeStr = showtime.getDate() + " @ " + showtime.getTime();
showtimeName = new JLabel(showtimeStr);
showtimeName.setForeground(Red);
costName = new JLabel("$12.50");
costName.setForeground(Red);
//seatName = new JLabel(app.getSeat());
JLabel movieLabel = new JLabel("Movie: ");
movieLabel.setForeground(Red);
JLabel theatreLabel = new JLabel("Theatre: ");
theatreLabel.setForeground(Red);
JLabel seatLabel = new JLabel("Seat: ");
seatLabel.setForeground(Red);
JLabel showtimeLabel = new JLabel("Showtime: ");
showtimeLabel.setForeground(Red);
JLabel costLabel = new JLabel("Cost: ");
costLabel.setForeground(Red);
int row = 0;
addComponent(clientPanel, movieLabel, 0, row, gbc);
addComponent(clientPanel, movieName, 1, row++, gbc);
addComponent(clientPanel, theatreLabel, 0, row, gbc);
addComponent(clientPanel, theatreName, 1, row++, gbc);
addComponent(clientPanel, seatLabel, 0, row, gbc);
addComponent(clientPanel, seatName, 1, row++, gbc);
addComponent(clientPanel, showtimeLabel, 0, row, gbc);
addComponent(clientPanel, showtimeName, 1, row++, gbc);
addComponent(clientPanel, costLabel, 0, row, gbc);
addComponent(clientPanel, costName, 1, row++, gbc);
this.add(clientPanel, BorderLayout.CENTER);
}
private void addComponent(JPanel panel, Component component, int gridx, int gridy, GridBagConstraints gbc) {
gbc.gridx = gridx;
gbc.gridy = gridy;
panel.add(component, gbc);
}
}