-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathStdHome.java
More file actions
120 lines (102 loc) · 2.83 KB
/
StdHome.java
File metadata and controls
120 lines (102 loc) · 2.83 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
package KYUTES;
import javax.swing.*;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
public class StdHome extends JFrame implements ActionListener{
public JFrame frame;
private JPanel stdHome;
private JButton account,score,exercises,test;
String userName,userPassword;
/*public static void main(String[] args) {
EventQueue.invokeLater(new Runnable() {
public void run() {
try {
StdHome window = new StdHome("???","123");
window.frame.setVisible(true);
} catch (Exception e) {
e.printStackTrace();
}
}
});
}*/
public void setVisible(boolean t) {
frame.setVisible(t);
}
public StdHome(String userName,String userPassword) {
this.userName = userName;
this.userPassword = userPassword;
initialize();
}
/*
* 學生功能選單(登入主頁)
*/
private void initialize() {
frame = new JFrame("學生功能選單");
frame.setSize(900, 600);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.getContentPane().setLayout(null);
BarPanel bar = new BarPanel(frame,userName);
// 學生主頁面板
stdHome = new JPanel();
stdHome.setBounds(0, 50, 900, 550);
stdHome.setBackground(new Color(186, 202, 224)); // RGB
stdHome.setLayout(null);
frame.getContentPane().add(stdHome);
// 個人帳號管理按鈕
account = new JButton("個人帳號管理");
account.setBounds(200, 100, 200, 100);
stdHome.add(account);
account.addActionListener(this);
// 成績查詢按鈕
score = new JButton("成績查詢");
score.setBounds(500, 100, 200, 100);
stdHome.add(score);
score.addActionListener(this);
// 練習按鈕
exercises = new JButton("練習");
exercises.setBounds(200, 300, 200, 100);
stdHome.add(exercises);
exercises.addActionListener(this);
// 測驗按鈕
test = new JButton("測驗");
test.setBounds(500, 300, 200, 100);
stdHome.add(test);
test.addActionListener(this);
}
@Override
public void actionPerformed(ActionEvent e) {
if(e.getSource()==account) {
try {
StdAccount window = new StdAccount(userName);
window.frame.setVisible(true);
} catch (Exception e1) {
e1.printStackTrace();
}
}
if(e.getSource()==score) {
try {
StdScore window = new StdScore(userName);
window.frame.setVisible(true);
} catch (Exception e1) {
e1.printStackTrace();
}
}
if(e.getSource()==exercises) {
try {
StdExercises window = new StdExercises(userName);
window.frame.setVisible(true);
} catch (Exception e1) {
e1.printStackTrace();
}
}
if(e.getSource()==test) {
try {
StdTest window = new StdTest(userName);
window.frame.setVisible(true);
} catch (Exception e1) {
e1.printStackTrace();
}
}
}
}