-
Notifications
You must be signed in to change notification settings - Fork 0
/
MainMenuBar.java
206 lines (171 loc) · 6.5 KB
/
MainMenuBar.java
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
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
//Generated by GuiGenie - Copyright (c) 2004 Mario Awad.
//Home Page http://guigenie.cjb.net - Check often for new versions!
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import javax.swing.event.*;
public class MainMenuBar extends JFrame implements ActionListener{//, MenuListener{
private EnrollmentSystem es;
private JMenuBar menu;
private JPanel registerPanel;
private JPanel editPanel;
private JPanel addPanel;
private JPanel openPanel;
private JPanel viewPanel;
public MainMenuBar(EnrollmentSystem es) {
super("Machine Project");
this.es = es;
this.menu = new JMenuBar();
this.registerPanel = new JPanel();
registerPanel = makeRegister();
this.editPanel = new JPanel();
editPanel = makeEdit();
this.addPanel = new JPanel();
this.openPanel = new JPanel();
this.viewPanel = new JPanel();
setDefaultCloseOperation (EXIT_ON_CLOSE);
initScreen();
setSize(500,500);
setVisible (true);
}
public void initScreen(){
JPanel p = new JPanel(new BorderLayout());
//construct preComponents
JMenu adminMenu = new JMenu ("Admin");
JMenuItem registerItem = new JMenuItem ("Register Student Account");
registerItem.addActionListener(this);
adminMenu.add (registerItem);
JMenuItem editItem = new JMenuItem ("Edit Student Account");
editItem.addActionListener(this);
adminMenu.add(editItem);
JMenuItem addItem = new JMenuItem ("Add Course");
addItem.addActionListener(this);
adminMenu.add(addItem);
JMenuItem openItem = new JMenuItem ("Open Section");
openItem.addActionListener(this);
adminMenu.add(openItem);
JMenuItem viewItem = new JMenuItem ("View Class List");
viewItem.addActionListener(this);
adminMenu.add(viewItem);
JMenuItem logoutItem = new JMenuItem("Logout");
logoutItem.addActionListener(this);
adminMenu.add(logoutItem);
JMenu studentMenu = new JMenu ("Student");
JMenuItem enlistItem = new JMenuItem ("Enlist In Section");
enlistItem.addActionListener(this);
studentMenu.add (enlistItem);
JMenuItem removeItem = new JMenuItem ("Remove Enlistment");
removeItem.addActionListener(this);
studentMenu.add (removeItem);
JMenuItem enrollItem = new JMenuItem ("Enroll");
enrollItem.addActionListener(this);
studentMenu.add (enrollItem);
JMenuItem eafItem = new JMenuItem ("View EAF");
eafItem.addActionListener(this);
studentMenu.add (eafItem);
logoutItem = new JMenuItem("Logout");
logoutItem.addActionListener(this);
studentMenu.add(logoutItem);
registerPanel.setVisible(false);
editPanel.setVisible(false);
//construct components
menu.add(adminMenu);
menu.add(studentMenu);
p.add(menu);
add(p,BorderLayout.NORTH);
add(registerPanel, BorderLayout.CENTER);
//add(editPanel, BorderLayout.CENTER);
if(es.getAdmin().getIsLogin()){
adminMenu.setEnabled(true);
studentMenu.setEnabled(false);
}
else if(es.getCurrentStudent().getIsLogin()){
adminMenu.setEnabled(false);
studentMenu.setEnabled(true);
if(es.getCurrentStudent().getIsEnrolled()){
enlistItem.setEnabled(false);
removeItem.setEnabled(false);
enrollItem.setEnabled(false);
eafItem.setEnabled(true);
}
else{
enlistItem.setEnabled(true);
removeItem.setEnabled(true);
enrollItem.setEnabled(true);
eafItem.setEnabled(false);
}
}
//add components
p.setBorder(BorderFactory.createTitledBorder(BorderFactory.createEtchedBorder(), "Menu Panel"));
p.setBackground(new Color(127,191,127));
}
public JPanel makeRegister(){
JPanel returnable = new JPanel(new FlowLayout());
RegisterGUI reg = new RegisterGUI(es);
reg.setVisible(false);
returnable.add(reg.getContentPane());
return returnable;
}
public JPanel makeEdit(){
JPanel returnable = new JPanel(new FlowLayout());
EditStudentGUI edit = new EditStudentGUI(es);
edit.setVisible(false);
returnable.add(edit.getContentPane());
return returnable;
}
@Override
public void actionPerformed(ActionEvent e){
if(e.getActionCommand().equals("Register Student Account")){
registerPanel.setVisible(true);
editPanel.setVisible(false);
addPanel.setVisible(false);
openPanel.setVisible(false);
viewPanel.setVisible(false);
}
if(e.getActionCommand().equals("Edit Student Account")){
}
if(e.getActionCommand().equals("Add Course")){
}
if(e.getActionCommand().equals("Open Section")){
}
if(e.getActionCommand().equals("View Class List")){
}
if(e.getActionCommand().equals("Enlist in Section")){
}
if(e.getActionCommand().equals("Remove Enlistment")){
}
if(e.getActionCommand().equals("Enroll")){
}
if(e.getActionCommand().equals("View EAF")){
}
if(e.getActionCommand().equals("Logout")){
LoginGUI login = new LoginGUI(es);
this.dispose();
}
}
/*
@Override
public void menuSelected(MenuEvent me){
if(me.getSource().equals("Register Student Account")){
System.out.println("Hello");
}
}
@Override
public void menuDeselected(MenuEvent me){
}
@Override
public void menuCanceled(MenuEvent me){
}*/
public static void main (String[] args) {
EnrollmentSystem es = new EnrollmentSystem();
Account a = new Account("admin", "DLSU");
Student yuta = new Student("11512709", "Komoro9!", "Inoue", "Yuta", 0, 10);
es.login(a);
//es.RegisterStudentAccount(yuta);
//es.logout();
//a = new Account("11512709", "Komoro9!");
//es.login(a);
//es.enroll();
MainMenuBar e = new MainMenuBar(es);
}
}