-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathShowFetchedData.java
More file actions
245 lines (196 loc) · 7.83 KB
/
ShowFetchedData.java
File metadata and controls
245 lines (196 loc) · 7.83 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
package StudentDatabase.gitRepo.StudentDatabaseSystem;
import java.awt.Dimension;
import java.awt.Font;
import java.awt.Point;
import java.awt.Toolkit;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.sql.*;
import java.sql.DriverManager;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.SwingConstants;
import javax.swing.*;
public class ShowFetchedData extends JFrame implements ActionListener{
Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
int Screenwidth = (int) screenSize.getWidth();
int ScreenHeight = (int) screenSize.getHeight();
int width, height;
int RollNo;
JLabel title, name, rollno, fathername, mothername, dob, email, gender, aadharcard, enrollment, address;
JLabel country, state, city, phoneno, percentage;
JLabel nameAns, rollnoAns, fathernameAns, mothernameAns, dobAns, emailAns, genderAns, aadharcardAns, enrollmentAns, addressAns;
JLabel countryAns, stateAns, cityAns, phonenoAns, percentageAns;
JButton back;
ResultSet result;
public ShowFetchedData(Point loc, ResultSet results, int w, int h) throws SQLException {
width = w;
height = h;
result = results;
createFrame(loc);
}
private void createFrame(Point loc) throws SQLException{
setLayout(null);
// comment following line before running main program
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
title = new JLabel("Student Information", SwingConstants.CENTER);
title.setBounds(50, 10, width - 100, 80);
title.setFont(new Font("", Font.PLAIN, 30));
add(title);
name = new JLabel("Name : ");
name.setBounds(50, 100, 100, 20);
add(name);
nameAns = new JLabel();
nameAns.setBounds(200, 100, 500, 20);
nameAns.setFont(new Font("", Font.PLAIN, 12));
add(nameAns);
rollno = new JLabel("Roll No. ");
rollno.setBounds(50, 125, 100, 20);
add(rollno);
rollnoAns = new JLabel();
rollnoAns.setBounds(200, 125, 500, 20);
rollnoAns.setFont(new Font("", Font.PLAIN, 12));
add(rollnoAns);
fathername = new JLabel("Father Name ");
fathername.setBounds(50, 150, 100, 20);
add(fathername);
fathernameAns = new JLabel();
fathernameAns.setBounds(200, 150, 500, 20);
fathernameAns.setFont(new Font("", Font.PLAIN, 12));
add(fathernameAns);
mothername = new JLabel("Mother Name ");
mothername.setBounds(50, 175, 100, 20);
add(mothername);
mothernameAns = new JLabel();
mothernameAns.setBounds(200, 175, 500, 20);
mothernameAns.setFont(new Font("", Font.PLAIN, 12));
add(mothernameAns);
dob = new JLabel("DOB ");
dob.setBounds(50, 200, 100, 20);
add(dob);
dobAns = new JLabel();
dobAns.setBounds(200, 200, 500, 20);
dobAns.setFont(new Font("", Font.PLAIN, 12));
add(dobAns);
email = new JLabel("Email ");
email.setBounds(50, 225, 100, 20);
add(email);
emailAns = new JLabel();
emailAns.setBounds(200, 225, 500, 20);
emailAns.setFont(new Font("", Font.PLAIN, 12));
add(emailAns);
gender = new JLabel("Gender ");
gender.setBounds(50, 250, 100, 20);
add(gender);
genderAns = new JLabel();
genderAns.setBounds(200, 250, 500, 20);
genderAns.setFont(new Font("", Font.PLAIN, 12));
add(genderAns);
aadharcard = new JLabel("Aadhar Card No. ");
aadharcard.setBounds(50, 275, 100, 20);
add(aadharcard);
aadharcardAns = new JLabel();
aadharcardAns.setBounds(200, 275, 500, 20);
aadharcardAns.setFont(new Font("", Font.PLAIN, 12));
add(aadharcardAns);
enrollment = new JLabel("Enrollment No. ");
enrollment.setBounds(50, 300, 100, 20);
add(enrollment);
enrollmentAns = new JLabel();
enrollmentAns.setBounds(200, 300, 500, 20);
enrollmentAns.setFont(new Font("", Font.PLAIN, 12));
add(enrollmentAns);
address = new JLabel("Address ");
address.setBounds(50, 325, 100, 20);
add(address);
addressAns = new JLabel();
addressAns.setBounds(200, 325, 500, 20);
addressAns.setFont(new Font("", Font.PLAIN, 12));
add(addressAns);
country = new JLabel("Country ");
country.setBounds(50, 350, 100, 20);
add(country);
countryAns = new JLabel();
countryAns.setBounds(200, 350, 500, 20);
countryAns.setFont(new Font("", Font.PLAIN, 12));
add(countryAns);
state = new JLabel("State ");
state.setBounds(50, 375, 100, 20);
add(state);
stateAns = new JLabel();
stateAns.setBounds(200, 375, 500, 20);
stateAns.setFont(new Font("", Font.PLAIN, 12));
add(stateAns);
city = new JLabel("City ");
city.setBounds(50, 400, 100, 20);
add(city);
cityAns = new JLabel();
cityAns.setBounds(200, 400, 500, 20);
cityAns.setFont(new Font("", Font.PLAIN, 12));
add(cityAns);
phoneno = new JLabel("Phone No. ");
phoneno.setBounds(50, 425, 100, 20);
add(phoneno);
phonenoAns = new JLabel();
phonenoAns.setBounds(200, 425, 500, 20);
phonenoAns.setFont(new Font("", Font.PLAIN, 12));
add(phonenoAns);
percentage = new JLabel("Percentage ");
percentage.setBounds(50, 450, 100, 20);
add(percentage);
percentageAns = new JLabel();
percentageAns.setBounds(200, 450, 500, 20);
percentageAns.setFont(new Font("", Font.PLAIN, 12));
add(percentageAns);
back = new JButton("Back");
back.setBounds(0, 500, 70, 30);
add(back);
back.addActionListener(this);
while(result.next()){
String ans = result.getString(1);
nameAns.setText(ans);
ans = result.getString(2);
rollnoAns.setText(ans);
ans = result.getString(3);
fathernameAns.setText(ans);
ans = result.getString(4);
mothernameAns.setText(ans);
ans = result.getString(5);
dobAns.setText(ans);
ans = result.getString(6);
emailAns.setText(ans);
ans = result.getString(7);
genderAns.setText(ans);
ans = result.getString(8);
aadharcardAns.setText(ans);
ans = result.getString(9);
enrollmentAns.setText(ans);
ans = result.getString(10);
addressAns.setText(ans);
ans = result.getString(11);
countryAns.setText(ans);
ans = result.getString(12);
stateAns.setText(ans);
ans = result.getString(13);
cityAns.setText(ans);
ans = result.getString(14);
phonenoAns.setText(ans);
ans = result.getString(15);
percentageAns.setText(ans);
}
setTitle("Student Database System");
setVisible(true);
setLocation(loc);
setSize(width, height);
}
public static void main(String args[]) throws SQLException{
// new ShowFetchedData(new Point(300, 100));
}
@Override
public void actionPerformed(ActionEvent e) {
if(e.getSource() == back){
new FetchData(getLocation(), getWidth(), getHeight());
dispose();
}
}
}