-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathInitialPanel.java
More file actions
103 lines (75 loc) · 3.42 KB
/
Copy pathInitialPanel.java
File metadata and controls
103 lines (75 loc) · 3.42 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
import javax.swing.*;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
public class InitialPanel extends JPanel {
private MovieTheatreApp app;
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 int bWidth = 100;
private int bHeight = 50;
public InitialPanel(MovieTheatreApp app) {
this.app = app;
this.setLayout(new GridLayout(3, 1));
this.setBackground(Yellow);
JPanel textPanel = new JPanel(new GridLayout(2, 1));
JLabel welcomeLabel = new JLabel("Welcome To", JLabel.CENTER);
welcomeLabel.setFont(new Font("Times New Roman", Font.PLAIN, 20));
welcomeLabel.setForeground(Color.WHITE);
JLabel acmeplexLabel = new JLabel("ACMEPLEX", JLabel.CENTER);
acmeplexLabel.setFont(new Font("Times New Roman", Font.BOLD, 50));
acmeplexLabel.setForeground(Color.WHITE);
textPanel.add(welcomeLabel);
textPanel.add(acmeplexLabel);
textPanel.setBackground(Orange);
JPanel buttonPanel = new JPanel(new FlowLayout(FlowLayout.CENTER, 50, 50)); // Use FlowLayout for better control
buttonPanel.setBackground(Red);
JButton loginButton = new JButton("Login");
loginButton.setPreferredSize(new Dimension(bWidth, bHeight));
loginButton.setForeground(Red);
JButton registerButton = new JButton("Sign Up");
registerButton.setPreferredSize(new Dimension(bWidth, bHeight));
registerButton.setForeground(Red);
JButton guestButton = new JButton("Continue as Guest");
guestButton.setPreferredSize(new Dimension(200, bHeight));
guestButton.setForeground(Red);
JButton adminButton = new JButton("Admin Login");
adminButton.setPreferredSize(new Dimension(bWidth, bHeight));
adminButton.setForeground(Red);
buttonPanel.add(loginButton);
buttonPanel.add(registerButton);
buttonPanel.add(guestButton);
buttonPanel.setBackground(Yellow);
loginButton.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
app.switchToLogin();
}
});
registerButton.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
app.setFromSignUp(true);
app.switchToRegister();
}
});
guestButton.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
app.setCurrentUser(0); // Indicate that the current user is a guest
GuestPanel guest = app.getGuestPanel();
guest.updateButtons();
app.switchToGuest();
}
});
adminButton.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
app.switchToAdmin();
}
});
JPanel adminButtonPanel = new JPanel(new FlowLayout(FlowLayout.RIGHT, 20, 20));
adminButtonPanel.setBackground(Yellow);
adminButtonPanel.add(adminButton, BorderLayout.EAST);
this.add(adminButtonPanel); // Admin button at top-right
this.add(textPanel); // Center the text panel vertically and horizontally
this.add(buttonPanel); // Bottom buttons centered
}
}