-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPanel1.java
More file actions
251 lines (193 loc) · 6.19 KB
/
Copy pathPanel1.java
File metadata and controls
251 lines (193 loc) · 6.19 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
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
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
import java.awt.AWTException;
import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Dimension;
import java.awt.Font;
import java.awt.Robot;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.InputEvent;
import javax.swing.JButton;
import javax.swing.JScrollPane;
import javax.swing.JTable;
import javax.swing.table.DefaultTableModel;
import javax.swing.table.JTableHeader;
//Justin Yoo
//Program Description:
//Oct 18, 2024
public class Panel1 extends CustomPanel
{
private BigDuty bigDuty;
JScrollPane pane;
private int numRows;
private String[] colHeadings;
private Object[][] data;
private String hover;
public Panel1(Dimension d, BigDuty bigDuty) {
super("", d);
}
public Panel1(String panelName, Dimension d, BorderLayout b, BigDuty bigduty, String[] colheadings, Object[][] data, String hover)
{
super(panelName, d, b);
bigDuty = bigduty;
colHeadings = colheadings;
this.data = data;
this.hover = hover;
//buttons
JButton b1 = new JButton("Reassign Duties"); //demo
b1.addActionListener(e -> {
System.out.println("Smartly Sorted!");
bigduty.clearDuties();
bigduty.assignDuties();
bigduty.getPane().refreshPanels();
});
JButton b2 = new JButton("Clear Duties"); //demo
b2.addActionListener(e -> {
bigduty.clearDuties();
});
JButton b3 = new JButton("East"); //demo
JButton b4 = new JButton("West"); //demo
//Add Buttons
this.add(b1, BorderLayout.NORTH);
this.add(b2, BorderLayout.SOUTH);
this.add(b3, BorderLayout.EAST);
this.add(b4, BorderLayout.WEST);
//testing data
//test filler
for(int i = 0; i < data.length; i++)
{ //basically import data kinda like teacher.getCourse(0).getName(); or .getCourseID() or something like that
Teacher t = bigDuty.getTeacher(i);
data[i][0] = t.getLastName();
data[i][1] = t.totalCourses();
data[i][2] = t.getDuties().size();
data[i][3] = t.getDepartment();
}
DefaultTableModel model = new DefaultTableModel(data, colHeadings) {
private static final long serialVersionUID = 1L;
@Override
public Class<?> getColumnClass(int column){
if(column > 0 || column < 9)
return Integer.class;
return super.getColumnClass(column);
}
public boolean isCellEditable(int row, int column) {
return false;
}
};
JTable table = new JTable(model);
table.setVisible(true);
table.setAutoCreateRowSorter(true);
table.setFont(new Font("Tratatello", Font.PLAIN, 14));
//*********************************************************************************************************//
this.add(table, BorderLayout.CENTER); //add table to the center
JTableHeader header = table.getTableHeader();
header.setBackground(Color.yellow);
pane = new JScrollPane(table);
table.setAutoResizeMode(JTable.AUTO_RESIZE_ALL_COLUMNS);
table.setGridColor(Color.LIGHT_GRAY);
this.add(pane);
}
public JScrollPane getPane()
{
return pane;
}
public void setPane(JScrollPane pane)
{
this.pane = pane;
}
public BigDuty getBigDuty()
{
return bigDuty;
}
public void setBigDuty(BigDuty bigDuty)
{
this.bigDuty = bigDuty;
}
public int getNumRows()
{
return numRows;
}
public void setNumRows(int numRows)
{
this.numRows = numRows;
}
public String[] getColHeadings()
{
return colHeadings;
}
public void setColHeadings(String[] colHeadings)
{
this.colHeadings = colHeadings;
}
public Object[][] getData()
{
return data;
}
public void setData(Object[][] data)
{
this.data = data;
}
public String getHover()
{
return hover;
}
public void setHover(String hover)
{
this.hover = hover;
}
@Override
public void refreshPanel() {
this.removeAll();
JButton b1 = new JButton("Reassign Duties"); //demo
b1.addActionListener(e -> {
System.out.println("Smartly Sorted!");
bigDuty.reassignDuties();
});
JButton b2 = new JButton("Clear Duties"); //demo
b2.addActionListener(e -> {
bigDuty.clearDuties();
});
JButton b3 = new JButton("East"); //demo
JButton b4 = new JButton("West"); //demo
//Add Buttons
this.add(b1, BorderLayout.NORTH);
this.add(b2, BorderLayout.SOUTH);
this.add(b3, BorderLayout.EAST);
this.add(b4, BorderLayout.WEST);
//testing data
//test filler
for(int i = 0; i < data.length; i++)
{ //basically import data kinda like teacher.getCourse(0).getName(); or .getCourseID() or something like that
Teacher t = bigDuty.getTeacher(i);
data[i][0] = t.getLastName();
data[i][1] = t.totalCourses();
data[i][2] = t.getDuties().size();
data[i][3] = t.getDepartment();
}
DefaultTableModel model = new DefaultTableModel(data, colHeadings) {
private static final long serialVersionUID = 1L;
@Override
public Class<?> getColumnClass(int column){
if(column > 0 || column < 9)
return Integer.class;
return super.getColumnClass(column);
}
public boolean isCellEditable(int row, int column) {
return false;
}
};
JTable table = new JTable(model);
table.setVisible(true);
table.setAutoCreateRowSorter(true);
table.setFont(new Font("Tratatello", Font.PLAIN, 14));
//*********************************************************************************************************//
this.add(table, BorderLayout.CENTER); //add table to the center
JTableHeader header = table.getTableHeader();
header.setBackground(Color.yellow);
pane = new JScrollPane(table);
table.setAutoResizeMode(JTable.AUTO_RESIZE_ALL_COLUMNS);
table.setGridColor(Color.LIGHT_GRAY);
this.add(pane);
super.refreshPanel();
}
}