-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathSuperviseCustomerPanel.java
171 lines (130 loc) · 4.35 KB
/
SuperviseCustomerPanel.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
package oodp;
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import java.util.*;
import javax.swing.event.ListSelectionEvent;
import javax.swing.event.ListSelectionListener;
public class SuperviseCustomerPanel extends JPanel implements ActionListener
{
private SuperviseCustomer list;
JPanel panel;
private JList studentList;// customer list
private JList professorList;// professor list
int status;
JButton student;
JButton professor;
JTextField id;
JTextField coupon;
JTextField point;
public SuperviseCustomerPanel()
{
panel = new JPanel();
list = new SuperviseCustomer();
student = new JButton("student");
professor = new JButton("professor");
panel.add(student,BorderLayout.NORTH);
panel.add(professor,BorderLayout.NORTH);
id = new JTextField(10);
coupon = new JTextField(10);
point = new JTextField(10);
id.setEditable(false);
panel.add(id,BorderLayout.SOUTH);
coupon.setEditable(false);
panel.add(coupon,BorderLayout.SOUTH);
point.setEditable(false);
panel.add(point,BorderLayout.SOUTH);
student.addActionListener(this);
professor.addActionListener(this);
}
public void actionPerformed(ActionEvent e){
Object event = e.getSource();
MainBoard.board.remove(MainBoard.board_panel);
MainBoard.board.repaint();
MainBoard.board.revalidate();
MainBoard.board_panel=this.panel;
MainBoard.board_panel.setBackground(Color.white);
MainBoard.board_panel.setBounds(150,40,650,560);
MainBoard.board.add(MainBoard.board_panel);
if(event == student){
studentList();
panel.add(studentList,BorderLayout.CENTER);
status = 1;
}
if(event == professor){
professorList();
panel.add(professorList,BorderLayout.CENTER);
panel.repaint();
status = 2;
}
}
public void studentList(){
panel.removeAll();
panel.repaint();
information();
studentList = new JList(list.getStudentList());
studentList.setBorder(BorderFactory.createLineBorder(Color.black, 1));
studentList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
studentList.addListSelectionListener(new ListListener());
}
public void professorList(){
panel.removeAll();
panel.repaint();
information();
professorList = new JList(list.getProfessorList());
professorList.setBorder(BorderFactory.createLineBorder(Color.black, 1));
professorList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION);
professorList.addListSelectionListener(new ListListener());
}
public void information(){
id = new JTextField(10);
coupon = new JTextField(10);
point = new JTextField(10);
id.setEditable(false);
panel.add(id,BorderLayout.SOUTH);
coupon.setEditable(false);
panel.add(coupon,BorderLayout.SOUTH);
point.setEditable(false);
panel.add(point,BorderLayout.SOUTH);
student = new JButton("student");
professor = new JButton("professor");
panel.add(student,BorderLayout.NORTH);
panel.add(professor,BorderLayout.NORTH);
student.addActionListener(this);
professor.addActionListener(this);
}
private class ListListener implements ListSelectionListener
{
public void valueChanged(ListSelectionEvent e)
{
if(status == 1){
studentChanged();
}
else{
professorChanged();
}
}
private void studentChanged(){
String idValue = (String) studentList.getSelectedValue();
Student value = (Student)list.findById(idValue);
try
{System.out.println(String.valueOf(value.getCoupon()));System.out.println(String.valueOf(value.getPoint()));
id.setText(idValue);
coupon.setText(String.valueOf(value.getCoupon()));
point.setText(String.valueOf(value.getPoint()));
}
catch( Exception e ){}
}
private void professorChanged(){
String idValue = (String) professorList.getSelectedValue();
Professor value = (Professor)list.findById(idValue);
try
{
id.setText(idValue);
coupon.setText(String.valueOf(value.getCoupon()));
point.setText("Not used");
}
catch( Exception e ){}
}
}
}