-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMainMenuView.java
More file actions
109 lines (84 loc) · 2.74 KB
/
Copy pathMainMenuView.java
File metadata and controls
109 lines (84 loc) · 2.74 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
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
public class MainMenuView extends JFrame{
private JPanel panel;
private JButton button0;
private JButton button1;
private JButton button2;
private JButton button3;
private JButton button4;
private JButton button5;
private JLabel label;
private AdminView controller;
public MainMenuView(AdminView controller){
this.controller=controller;
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
setBounds(100, 100, 450, 300);
panel = new JPanel();
label = new JLabel("Frame 1");
button0 = new JButton("Create a booking");
button0.addActionListener(new ButtonListener());
button1 = new JButton("Create a Facility");
button1.addActionListener(new CreateFacilityButtonListener());
button2 = new JButton("View bookings");
button2.addActionListener(new ViewBookingButtonListener());
button3 = new JButton("Search Facility");
button3.addActionListener(new SearchFacilityButtonListener());
button4 = new JButton("Change Password");
button4.addActionListener(new ChangeAdminPasswordButtonListener());
button5 = new JButton("Log Out");
button5.addActionListener(new LogoutButtonListener());
getContentPane().setLayout(new BoxLayout(getContentPane(), BoxLayout.X_AXIS));
//panel.add(label);
if (controller.isAdmin()){
panel.add(button1);
panel.add(button2);
panel.add(button3);
panel.add(button4);
panel.add(button5);
}
else {
panel.add(button0);
panel.add(button2);
panel.add(button3);
panel.add(button4);
panel.add(button5);
}
panel.setLayout(new BoxLayout(panel,BoxLayout.Y_AXIS));
panel.setBorder(BorderFactory.createTitledBorder("ADMIN MAIN MENU"));
panel.setLayout(new GridLayout(6,1));
panel.setBackground(Color.white);
getContentPane().add(panel);
}
private class ButtonListener implements ActionListener{
public void actionPerformed(ActionEvent e){
controller.frameCreateBooking();
}
}
private class CreateFacilityButtonListener implements ActionListener{
public void actionPerformed(ActionEvent e){
controller.frameCreateFacility();
}
}
private class ViewBookingButtonListener implements ActionListener{
public void actionPerformed(ActionEvent e){
controller.frameViewBooking();
}
}
private class SearchFacilityButtonListener implements ActionListener{
public void actionPerformed(ActionEvent e){
controller.frameSearchFacility();
}
}
private class LogoutButtonListener implements ActionListener{
public void actionPerformed(ActionEvent e){
controller.logOut();
}
}
private class ChangeAdminPasswordButtonListener implements ActionListener{
public void actionPerformed(ActionEvent e){
controller.frameChangeAdminPassword();
}
}
}