-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path0StudentPastSession.java
182 lines (167 loc) · 6.93 KB
/
0StudentPastSession.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
172
173
174
175
176
177
178
179
180
181
182
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package cdvirtualclient;
import Resource.RequestCodes;
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;
import java.io.*;
import java.util.Vector;
/**
*
* @author Chayan-Dhaddha
*/
public class StudentPastSession extends JPanel implements ActionListener{
Vector<String> HEAD;
Vector DATA;
JTable table;
JScrollPane jsp;
JLabel lbl_filter,lbl_date_from,lbl_date_to;
JRadioButton rbtn_date,rbtn_session,rbtn_search;
ButtonGroup grp;
JButton btn_fetch;
JTextField txt_search,txt_session;
Choice drop_session,drop_date_from_day,drop_date_from_month,drop_date_from_year,drop_date_to_day,drop_date_to_month,drop_date_to_year;
int flag;
public StudentPastSession(){
this.setLayout(null);
lbl_filter=new JLabel("FILTER ::");
rbtn_date=new JRadioButton("Date:",true);
rbtn_session=new JRadioButton("Session by:");
rbtn_search=new JRadioButton("Search by:");
rbtn_date.setActionCommand("date");
rbtn_session.setActionCommand("session");
rbtn_search.setActionCommand("search");
grp=new ButtonGroup();
grp.add(rbtn_date);
grp.add(rbtn_search);
grp.add(rbtn_session);
btn_fetch=new JButton("FETCH");
lbl_date_from=new JLabel("From: ");
lbl_date_to=new JLabel("To: ");
drop_date_from_day=new Choice();
drop_date_from_month=new Choice();
drop_date_from_year=new Choice();
drop_date_to_day=new Choice();
drop_date_to_month=new Choice();
drop_date_to_year=new Choice();
for(int i=1;i<=31;i++){
drop_date_from_day.add(""+i);
drop_date_to_day.add(""+i);
}
for(int i=1;i<=12;i++){
drop_date_from_month.add(""+i);
drop_date_to_month.add(""+i);
}
for(int i=2012;i<=2016;i++){
drop_date_from_year.add(""+i);
drop_date_to_year.add(""+i);
}
txt_session=new JTextField();
txt_search=new JTextField();
txt_session.setVisible(false);
txt_search.setVisible(false);
HEAD=new Vector<String>();
HEAD.add("INITIATED_BY");
HEAD.add("TOPIC");
HEAD.add("DATE");
HEAD.add("TIME");
HEAD.add("DURATION");
DATA=new Vector();
table=new JTable(DATA,HEAD);
jsp=new JScrollPane(table, JScrollPane.VERTICAL_SCROLLBAR_ALWAYS,JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS);
this.design();
//grp.getSelection().addActionListener(this);
rbtn_date.addActionListener(this);
rbtn_session.addActionListener(this);
rbtn_search.addActionListener(this);
btn_fetch.addActionListener(this);
}
void design(){
this.setPosition(lbl_filter,80,20,100,30);
this.setPosition(rbtn_date,220,20,100,30);
this.setPosition(lbl_date_from,350,20,50,30);
this.setPosition(drop_date_from_day,400,20,40,30);
this.setPosition(drop_date_from_month,440,20,40,30);
this.setPosition(drop_date_from_year,480,20,60,30);
this.setPosition(lbl_date_to,570,20,30,30);
this.setPosition(drop_date_to_day,600,20,40,30);
this.setPosition(drop_date_to_month,640,20,40,30);
this.setPosition(drop_date_to_year,680,20,60,30);
this.setPosition(rbtn_session,220,60,100,30);
this.setPosition(txt_session,350,60,220,30);
this.setPosition(rbtn_search,220,100,100,30);
this.setPosition(txt_search,350,100,220,30);
this.setPosition(btn_fetch,800,100,100,30);
this.setPosition(jsp,50,180,1200,460);
}
void setPosition(Component C,int x,int y,int w,int h){
this.add(C);
C.setBounds(x,y,w,h);
}
public void actionPerformed(ActionEvent ae){
if(ae.getSource()==btn_fetch){
try{
ObjectOutputStream out=new ObjectOutputStream(CommResource.client.getOutputStream());
out.writeObject(RequestCodes.FILTER_PAST_SESSION);
if(flag==1){
out.writeObject(RequestCodes.FILTER_DATE);
String date_from=drop_date_from_year.getSelectedItem()+"/"+drop_date_from_month.getSelectedItem()+drop_date_from_day.getSelectedItem();
String date_to=drop_date_to_year.getSelectedItem()+"/"+drop_date_to_month.getSelectedItem()+drop_date_to_day.getSelectedItem();
out.writeObject(date_from);
out.writeObject(date_to);
}
else if(flag==2){
out.writeObject(RequestCodes.FILTER_SESSION);
out.writeObject(txt_session.getText());
}
else{
out.writeObject(RequestCodes.FILTER_SEARCH);
out.writeObject(txt_search.getText());
}
}catch(Exception ex){
}
}else if(ae.getSource()==rbtn_date){
lbl_date_from.setVisible(true);
lbl_date_to.setVisible(true);
drop_date_from_day.setVisible(true);
drop_date_from_month.setVisible(true);
drop_date_from_year.setVisible(true);
drop_date_to_day.setVisible(true);
drop_date_to_month.setVisible(true);
drop_date_to_year.setVisible(true);
txt_session.setVisible(false);
txt_search.setVisible(false);
flag=1;
}
else if(ae.getSource()==rbtn_session){
lbl_date_from.setVisible(false);
lbl_date_to.setVisible(false);
drop_date_from_day.setVisible(false);
drop_date_from_month.setVisible(false);
drop_date_from_year.setVisible(false);
drop_date_to_day.setVisible(false);
drop_date_to_month.setVisible(false);
drop_date_to_year.setVisible(false);
txt_session.setVisible(true);
txt_search.setVisible(false);
flag=2;
}
else if(ae.getSource()==rbtn_search){
lbl_date_from.setVisible(false);
lbl_date_to.setVisible(false);
drop_date_from_day.setVisible(false);
drop_date_from_month.setVisible(false);
drop_date_from_year.setVisible(false);
drop_date_to_day.setVisible(false);
drop_date_to_month.setVisible(false);
drop_date_to_year.setVisible(false);
txt_session.setVisible(false);
txt_search.setVisible(true);
flag=3;
}
}
}