forked from rishaav/pClick
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathView class
More file actions
117 lines (97 loc) · 3.24 KB
/
View class
File metadata and controls
117 lines (97 loc) · 3.24 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
public class View {
private Model model1;
private Controller controller1;
private Jtable classtable;
private Jtable sessiontable;
private Jtable reporttable;
private JButton report;
private JButton session;
private int numsession;
private int numquestion;
public View(Model m) {
this.model1=m;
/*
** DRAW CLASS TABLE WITH ONLY ONE COLUMN
** ________________
**|Class |
**|----------------|
**|CS141 |
**|----------------|
**|CS142 |
**|________________| */
String[] column = {"Class"};
//actual data for the table
Object[][] data = new Object[][] {
{"CS141"},
{"CS142"},
{"CS214"},
};
//create table with data
classtable= new JTable(data, column);
//add the table to the frame
this.add(new JScrollPane(table));
this.setTitle("Classes");
this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
this.pack();
this.setVisible(true);
}
/*
** DRAW CLASS TABLE WITH ONLY ONE COLUMN
** ________________
**|Session |
**|----------------|
**|Session 1 |
**|----------------|
**|Session 2 |
**|________________| */
public void drawsessiontable(String ClassID)
String[] columns = {ClassID+ " session"};
//actual data for the table
Object[][] datas = new Object[][] ;
//get the number of session for this class
numsession=model1.ClassID.numsession;
//fill the row with Session number
for (int row=1; row<=numsession;i++){
session= new JButton(""Session" +row ");
datas[0][row]=session;
}
//create table with data
sessiontable= new JTable(datas, columns);
//add the table to the frame
this.add(new JScrollPane(table));
this.setTitle("List of Session");
this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
this.pack();
this.setVisible(true);
}
/*
** DRAW CLASS TABLE WITH ONLY TWO COLUMN
** ____________________________
**|Question |Report |
**|----------------|-----------|
**|Question 1 |Open Report|
**|----------------|-----------|
**|Question 2 |Open Report|
**|________________|___________| */
public void drawreporttable(String ClassID, String ClassSession)
String[] columnss = {"Question","Report"};
//actual data for the table
Object[][] datass = new Object[][] ;
//get the number of question for this class session
numquestion=model1.ClassID.ClassSession.numquestion;
//fill the row with Session number
report=new JButton("Open report");
for (int row=1; row<=numquestion;i++){
datass[0][row]="Question"+row;
datass[1][row]=report;
}
//create table with data
reporttable= new JTable(datass, columnss);
//add the table to the frame
this.add(new JScrollPane(table));
this.setTitle(Report");
this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
this.pack();
this.setVisible(true);
}
}