-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathStark_Industries_DETAILS.java
More file actions
503 lines (433 loc) · 18.9 KB
/
Stark_Industries_DETAILS.java
File metadata and controls
503 lines (433 loc) · 18.9 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
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
/*
* 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 stark.industries;
import java.sql.*;
import javax.swing.JOptionPane;
import java.awt.*;
import java.awt.event.*;
import net.proteanit.sql.DbUtils;
/**
*
* @author DarkGamerX100
*/
public class Stark_Industries_DETAILS extends javax.swing.JFrame {
/**
* Creates new form Stark_Industries_DETAILS
*/
public Stark_Industries_DETAILS() {
initComponents();
laID.setVisible(false);
lA.setVisible(false);
lC.setVisible(false);
lD.setVisible(false);
lG.setVisible(false);
lN.setVisible(false);
lS.setVisible(false);
lC.setVisible(false);
tID.setVisible(false);
tname.setVisible(false);
txtGen.setVisible(false);
tDept.setVisible(false);
tSal.setVisible(false);
tAdd.setVisible(false);
tCon.setVisible(false);
btn_Search.setVisible(false);
employer_icon.setVisible(false);
jScrollPane1.setVisible(false);
}
/**
* This method is called from within the constructor to initialize the form.
* WARNING: Do NOT modify this code. The content of this method is always
* regenerated by the Form Editor.
*/
@SuppressWarnings("unchecked")
// <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
private void initComponents() {
buttonGroup1 = new javax.swing.ButtonGroup();
jPanel1 = new javax.swing.JPanel();
laID = new javax.swing.JLabel();
lN = new javax.swing.JLabel();
lD = new javax.swing.JLabel();
lS = new javax.swing.JLabel();
lA = new javax.swing.JLabel();
lC = new javax.swing.JLabel();
tID = new javax.swing.JTextField();
tname = new javax.swing.JTextField();
tDept = new javax.swing.JTextField();
tSal = new javax.swing.JTextField();
tAdd = new javax.swing.JTextField();
tCon = new javax.swing.JTextField();
jButton1 = new javax.swing.JButton();
btn_Search = new javax.swing.JButton();
lG = new javax.swing.JLabel();
txtGen = new javax.swing.JTextField();
employer_icon = new javax.swing.JLabel();
jScrollPane1 = new javax.swing.JScrollPane();
empTable = new javax.swing.JTable();
radListAll = new javax.swing.JRadioButton();
radSearch = new javax.swing.JRadioButton();
btn_Next = new javax.swing.JButton();
jLabel2 = new javax.swing.JLabel();
setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
setTitle("STARK INDUSTRIES Employer Details");
jPanel1.setLayout(null);
laID.setFont(new java.awt.Font("Tahoma", 0, 36)); // NOI18N
laID.setForeground(new java.awt.Color(153, 0, 153));
laID.setText("ID");
jPanel1.add(laID);
laID.setBounds(30, 170, 150, 30);
lN.setFont(new java.awt.Font("Tahoma", 0, 36)); // NOI18N
lN.setForeground(new java.awt.Color(153, 0, 153));
lN.setText("NAME");
jPanel1.add(lN);
lN.setBounds(30, 280, 100, 30);
lD.setFont(new java.awt.Font("Tahoma", 0, 36)); // NOI18N
lD.setForeground(new java.awt.Color(153, 0, 153));
lD.setText("DEPARMENT");
jPanel1.add(lD);
lD.setBounds(30, 470, 210, 30);
lS.setFont(new java.awt.Font("Tahoma", 0, 36)); // NOI18N
lS.setForeground(new java.awt.Color(153, 0, 153));
lS.setText("SALARY");
jPanel1.add(lS);
lS.setBounds(30, 560, 180, 30);
lA.setFont(new java.awt.Font("Tahoma", 0, 36)); // NOI18N
lA.setForeground(new java.awt.Color(153, 0, 153));
lA.setText("ADDRESS");
jPanel1.add(lA);
lA.setBounds(30, 650, 180, 30);
lC.setFont(new java.awt.Font("Tahoma", 0, 36)); // NOI18N
lC.setForeground(new java.awt.Color(153, 0, 153));
lC.setText("CONTACT");
jPanel1.add(lC);
lC.setBounds(30, 740, 200, 30);
tID.setFont(new java.awt.Font("Tahoma", 0, 36)); // NOI18N
tID.setForeground(new java.awt.Color(204, 0, 51));
jPanel1.add(tID);
tID.setBounds(280, 160, 360, 50);
tname.setEditable(false);
tname.setFont(new java.awt.Font("Tahoma", 0, 24)); // NOI18N
tname.setForeground(new java.awt.Color(255, 51, 102));
jPanel1.add(tname);
tname.setBounds(280, 270, 360, 50);
tDept.setEditable(false);
tDept.setFont(new java.awt.Font("Tahoma", 0, 24)); // NOI18N
tDept.setForeground(new java.awt.Color(255, 51, 51));
jPanel1.add(tDept);
tDept.setBounds(280, 460, 360, 50);
tSal.setEditable(false);
tSal.setFont(new java.awt.Font("Tahoma", 0, 24)); // NOI18N
tSal.setForeground(new java.awt.Color(255, 51, 51));
jPanel1.add(tSal);
tSal.setBounds(280, 550, 360, 50);
tAdd.setEditable(false);
tAdd.setFont(new java.awt.Font("Tahoma", 0, 24)); // NOI18N
tAdd.setForeground(new java.awt.Color(255, 51, 51));
jPanel1.add(tAdd);
tAdd.setBounds(280, 640, 360, 50);
tCon.setEditable(false);
tCon.setFont(new java.awt.Font("Tahoma", 0, 24)); // NOI18N
tCon.setForeground(new java.awt.Color(255, 51, 51));
jPanel1.add(tCon);
tCon.setBounds(280, 730, 360, 50);
jButton1.setFont(new java.awt.Font("Tahoma", 0, 24)); // NOI18N
jButton1.setForeground(new java.awt.Color(255, 102, 102));
jButton1.setText("RETURN");
jButton1.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(0, 0, 0), 3));
jButton1.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton1ActionPerformed(evt);
}
});
jPanel1.add(jButton1);
jButton1.setBounds(1160, 700, 150, 50);
btn_Search.setFont(new java.awt.Font("Tahoma", 0, 24)); // NOI18N
btn_Search.setForeground(new java.awt.Color(255, 0, 0));
btn_Search.setText("SEARCH");
btn_Search.setBorder(new javax.swing.border.LineBorder(new java.awt.Color(0, 0, 0), 3, true));
btn_Search.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
btn_SearchActionPerformed(evt);
}
});
jPanel1.add(btn_Search);
btn_Search.setBounds(670, 160, 190, 50);
lG.setFont(new java.awt.Font("Tahoma", 0, 36)); // NOI18N
lG.setForeground(new java.awt.Color(153, 0, 153));
lG.setText("GENDER");
jPanel1.add(lG);
lG.setBounds(30, 370, 180, 50);
txtGen.setEditable(false);
txtGen.setFont(new java.awt.Font("Tahoma", 0, 24)); // NOI18N
txtGen.setForeground(new java.awt.Color(255, 51, 51));
jPanel1.add(txtGen);
txtGen.setBounds(280, 370, 360, 50);
employer_icon.setIcon(new javax.swing.ImageIcon(getClass().getResource("/stark/industries/employer.jpg"))); // NOI18N
jPanel1.add(employer_icon);
employer_icon.setBounds(1020, 110, 300, 300);
empTable.setBackground(new java.awt.Color(204, 0, 102));
empTable.setFont(new java.awt.Font("Tahoma", 0, 18)); // NOI18N
empTable.setModel(new javax.swing.table.DefaultTableModel(
new Object [][] {
{null, null, null, null, null, null, null},
{null, null, null, null, null, null, null},
{null, null, null, null, null, null, null},
{null, null, null, null, null, null, null},
{null, null, null, null, null, null, null},
{null, null, null, null, null, null, null},
{null, null, null, null, null, null, null},
{null, null, null, null, null, null, null},
{null, null, null, null, null, null, null},
{null, null, null, null, null, null, null},
{null, null, null, null, null, null, null},
{null, null, null, null, null, null, null},
{null, null, null, null, null, null, null},
{null, null, null, null, null, null, null},
{null, null, null, null, null, null, null},
{null, null, null, null, null, null, null},
{null, null, null, null, null, null, null},
{null, null, null, null, null, null, null},
{null, null, null, null, null, null, null}
},
new String [] {
"ID", "Name", "Department", "Salary", "Address", "Contact Number", "Gender"
}
) {
Class[] types = new Class [] {
java.lang.Integer.class, java.lang.String.class, java.lang.String.class, java.lang.Double.class, java.lang.String.class, java.lang.String.class, java.lang.String.class
};
public Class getColumnClass(int columnIndex) {
return types [columnIndex];
}
});
jScrollPane1.setViewportView(empTable);
jPanel1.add(jScrollPane1);
jScrollPane1.setBounds(20, 210, 1120, 580);
buttonGroup1.add(radListAll);
radListAll.setFont(new java.awt.Font("Tahoma", 1, 24)); // NOI18N
radListAll.setForeground(new java.awt.Color(255, 0, 0));
radListAll.setText("List All Employers");
jPanel1.add(radListAll);
radListAll.setBounds(30, 20, 400, 40);
buttonGroup1.add(radSearch);
radSearch.setFont(new java.awt.Font("Tahoma", 1, 24)); // NOI18N
radSearch.setForeground(new java.awt.Color(255, 0, 0));
radSearch.setText("Search");
jPanel1.add(radSearch);
radSearch.setBounds(30, 70, 300, 40);
btn_Next.setFont(new java.awt.Font("Tahoma", 1, 36)); // NOI18N
btn_Next.setForeground(new java.awt.Color(102, 102, 102));
btn_Next.setText("NEXT");
btn_Next.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
btn_NextActionPerformed(evt);
}
});
jPanel1.add(btn_Next);
btn_Next.setBounds(290, 70, 180, 40);
jLabel2.setIcon(new javax.swing.ImageIcon(getClass().getResource("/stark/industries/Details.jpg"))); // NOI18N
jPanel1.add(jLabel2);
jLabel2.setBounds(0, 0, 1370, 810);
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
getContentPane().setLayout(layout);
layout.setHorizontalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, 1367, Short.MAX_VALUE)
);
layout.setVerticalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, 809, Short.MAX_VALUE)
);
pack();
}// </editor-fold>//GEN-END:initComponents
Statement stmt = null;
ResultSet rs = null;
public static Connection getConnection(){
Connection con=null;
try{
Class.forName("com.mysql.jdbc.Driver");
con=DriverManager.getConnection("jdbc:mysql://localhost:3306/stark_industries","root","stid");
}
catch (Exception ex){
JOptionPane.showMessageDialog(null, "Stark Server Connection Failure");
}
return con;
}
private void btn_SearchActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btn_SearchActionPerformed
// TODO add your handling code here:
lA.setVisible(true);
lC.setVisible(true);
lD.setVisible(true);
lG.setVisible(true);
lN.setVisible(true);
lS.setVisible(true);
lC.setVisible(true);
tname.setVisible(true);
txtGen.setVisible(true);
tDept.setVisible(true);
tSal.setVisible(true);
tAdd.setVisible(true);
tCon.setVisible(true);
String un=tID.getText();
PreparedStatement pstmt;
pstmt = null;
Connection conn=null;
ResultSet rs = null;
try{
Class.forName("com.mysql.jdbc.Driver");
conn=DriverManager.getConnection("jdbc:mysql://localhost:3306/stark_industries","root","stid");
pstmt=conn.prepareStatement("select * from employer where ID=?");
pstmt.setString(1, un);
rs=pstmt.executeQuery();
while(rs.next()){
tname.setText(rs.getString("Name"));
tDept.setText(rs.getString("Department"));
tSal.setText(rs.getString("Salary"));
tAdd.setText(rs.getString("Address"));
tCon.setText(rs.getString("Contact"));
txtGen.setText(rs.getString("Gender"));
employer_icon.setVisible(true);
}
}
catch(Exception ex){
JOptionPane.showMessageDialog(null, ex.toString());
}
finally{
try{
conn.close();
pstmt.close();
rs.close();
}
catch(Exception ex){
}
}
}//GEN-LAST:event_btn_SearchActionPerformed
public void close(){
WindowEvent winClosingEvent = new WindowEvent(this,WindowEvent.WINDOW_CLOSING);
Toolkit.getDefaultToolkit().getSystemEventQueue().postEvent(winClosingEvent);
}
private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton1ActionPerformed
// TODO add your handling code here:
JOptionPane.showMessageDialog(null, "Exiting Employer Search Window...");
Stark_Industries_ADMIN gy = new Stark_Industries_ADMIN();
gy.setVisible(true);
close();
}//GEN-LAST:event_jButton1ActionPerformed
private void btn_NextActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btn_NextActionPerformed
// TODO add your handling code here:
if(radListAll.isSelected())
{
lA.setVisible(false);
lC.setVisible(false);
lD.setVisible(false);
lG.setVisible(false);
lN.setVisible(false);
lS.setVisible(false);
lC.setVisible(false);
tname.setVisible(false);
txtGen.setVisible(false);
tDept.setVisible(false);
tSal.setVisible(false);
tAdd.setVisible(false);
tCon.setVisible(false);
laID.setVisible(false);
tID.setVisible(false);
btn_Search.setVisible(false);
employer_icon.setVisible(false);
jScrollPane1.setVisible(true);
PreparedStatement pstmt;
pstmt = null;
Connection conn=null;
ResultSet rs = null;
try{
Class.forName("com.mysql.jdbc.Driver");
conn=DriverManager.getConnection("jdbc:mysql://localhost:3306/stark_industries","root","stid");
String sql="select * from employer";
pstmt=conn.prepareStatement(sql);
rs=pstmt.executeQuery();
empTable.setModel(DbUtils.resultSetToTableModel(rs));
}
catch(Exception ex){
JOptionPane.showMessageDialog(null, ex.getMessage());
}
finally{
try{
rs.close();
pstmt.close();
}
catch(Exception ex){}}
}
else if(radSearch.isSelected()){
jScrollPane1.setVisible(false);
laID.setVisible(true);
tID.setVisible(true);
btn_Search.setVisible(true);
}
}//GEN-LAST:event_btn_NextActionPerformed
/**
* @param args the command line arguments
*/
public static void main(String args[]) {
/* Set the Nimbus look and feel */
//<editor-fold defaultstate="collapsed" desc=" Look and feel setting code (optional) ">
/* If Nimbus (introduced in Java SE 6) is not available, stay with the default look and feel.
* For details see http://download.oracle.com/javase/tutorial/uiswing/lookandfeel/plaf.html
*/
try {
for (javax.swing.UIManager.LookAndFeelInfo info : javax.swing.UIManager.getInstalledLookAndFeels()) {
if ("Nimbus".equals(info.getName())) {
javax.swing.UIManager.setLookAndFeel(info.getClassName());
break;
}
}
} catch (ClassNotFoundException ex) {
java.util.logging.Logger.getLogger(Stark_Industries_DETAILS.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (InstantiationException ex) {
java.util.logging.Logger.getLogger(Stark_Industries_DETAILS.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (IllegalAccessException ex) {
java.util.logging.Logger.getLogger(Stark_Industries_DETAILS.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (javax.swing.UnsupportedLookAndFeelException ex) {
java.util.logging.Logger.getLogger(Stark_Industries_DETAILS.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
}
//</editor-fold>
/* Create and display the form */
java.awt.EventQueue.invokeLater(new Runnable() {
public void run() {
new Stark_Industries_DETAILS().setVisible(true);
}
});
}
// Variables declaration - do not modify//GEN-BEGIN:variables
private javax.swing.JButton btn_Next;
private javax.swing.JButton btn_Search;
private javax.swing.ButtonGroup buttonGroup1;
private javax.swing.JTable empTable;
private javax.swing.JLabel employer_icon;
private javax.swing.JButton jButton1;
private javax.swing.JLabel jLabel2;
private javax.swing.JPanel jPanel1;
private javax.swing.JScrollPane jScrollPane1;
private javax.swing.JLabel lA;
private javax.swing.JLabel lC;
private javax.swing.JLabel lD;
private javax.swing.JLabel lG;
private javax.swing.JLabel lN;
private javax.swing.JLabel lS;
private javax.swing.JLabel laID;
private javax.swing.JRadioButton radListAll;
private javax.swing.JRadioButton radSearch;
public static javax.swing.JTextField tAdd;
public static javax.swing.JTextField tCon;
public static javax.swing.JTextField tDept;
public static transient volatile javax.swing.JTextField tID;
public static javax.swing.JTextField tSal;
public static transient volatile javax.swing.JTextField tname;
private javax.swing.JTextField txtGen;
// End of variables declaration//GEN-END:variables
void Close() {
throw new UnsupportedOperationException("Not supported yet."); //To change body of generated methods, choose Tools | Templates.
}
}