-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPanel4.java
More file actions
102 lines (63 loc) · 2.77 KB
/
Copy pathPanel4.java
File metadata and controls
102 lines (63 loc) · 2.77 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
//Dylan Barrett
//Description
//11/11/24
import javax.swing.*;
import javax.swing.border.Border;
import javax.swing.table.DefaultTableModel;
import java.awt.*;
import java.util.ArrayList;
public class Panel4 extends CustomPanel {
private final BigDuty bigDuty;
private final Border border;
private final String[] column;
private final int teacherIndex;
public Panel4(String panelName, Dimension d, BigDuty bigDuty) {
super(panelName, d);
this.bigDuty = bigDuty;
this.teacherIndex = 4;
this.border = BorderFactory.createLineBorder(Color.BLACK);
GridLayout week = new GridLayout(1, 5);
CustomPanel[] weekPanels = new CustomPanel[5];
this.setLayout(week);
String[] dayNames = {"M", "T", "W", "R", "F"};
for(int x = 0; x < 5; x++) {
weekPanels[x] = new CustomPanel(dayNames[x], new Dimension(100, 100));
weekPanels[x].setLayout(new BorderLayout());
GridLayout monday = new GridLayout(9, 1);
GridLayout other = new GridLayout(7, 1);
if(x == 0) weekPanels[x].setLayout(monday);
else weekPanels[x].setLayout(other);
this.add(weekPanels[x]);
weekPanels[x].setBorder(border);
}
column = new String[1];
column[0] = "Duties";
for(int x = 0; x < dayNames.length; x++) {
int offset = x == 0 ? 1 : 0;
for (int y = 1; y <= ((GridLayout) (weekPanels[x].getLayout())).getRows() - offset; y++) {
JScrollPane table = null;
if(x != 0 && y == 4) {
table = createDylanTable(bigDuty.getTeacher(teacherIndex).getDayLunch(dayNames[x]));
} else table = createDylanTable(bigDuty.getTeacher(teacherIndex).getAssignment(dayNames[x], new Period(y)));
weekPanels[x].add(table);
if (x == 0 && y == 4) {
weekPanels[x].add(createDylanTable(bigDuty.getTeacher(teacherIndex).getDayLunch(dayNames[x])));
}
}
}
}
public JScrollPane createDylanTable(Assignment assignment) {
String[][] data = new String[1][1];
for(int i = 0; i < 1; i++) {
if(assignment != null) data[i][0] = String.valueOf(assignment.getTeacher().scoreAssignment(assignment));
else data[i][0] = "null";
if(assignment != null && assignment instanceof Lunch) data[i][0] = "Lunch";
}
DefaultTableModel tm = new DefaultTableModel(data, column); //eventual data implementation, make data have things
JTable t = new JTable(tm);
t.setBorder(border);
t.setAutoResizeMode(JTable.AUTO_RESIZE_ALL_COLUMNS);
JScrollPane sp = new JScrollPane(t);
return sp;
}
}