-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathStark_Industries_HOME.java
More file actions
230 lines (191 loc) · 8.87 KB
/
Stark_Industries_HOME.java
File metadata and controls
230 lines (191 loc) · 8.87 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
/*
* 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 javax.swing.JOptionPane;
import java.awt.*;
import java.awt.event.*;
import java.io.File;
import java.sql.*;
import javafx.embed.swing.JFXPanel;
import javafx.scene.media.Media;
import javafx.scene.media.MediaPlayer;
/**
*
* @author DarkGamerX100
*/
public class Stark_Industries_HOME extends javax.swing.JFrame {
/** Creates new form Stark_Industries_HOME */
public Stark_Industries_HOME() {
initComponents();
Welcome_Speech();
}
public void Welcome_Speech(){
try{
JFXPanel j = new JFXPanel();
String uri = new File("Login.mp3").toURI().toString();
new MediaPlayer(new Media(uri)).play();;
}
catch(Exception ex){
System.out.println(ex);
}
}
/** 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() {
jPanel1 = new javax.swing.JPanel();
jLabel2 = new javax.swing.JLabel();
jLabel3 = new javax.swing.JLabel();
txtUsername = new javax.swing.JTextField();
btn_logon = new javax.swing.JButton();
txtPasskey = new javax.swing.JPasswordField();
jLabel1 = new javax.swing.JLabel();
setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
setTitle("STARK INDUSTRIES LOGIN");
jPanel1.setLayout(null);
jLabel2.setFont(new java.awt.Font("Tahoma", 1, 36)); // NOI18N
jLabel2.setForeground(new java.awt.Color(255, 51, 0));
jLabel2.setText("USER NAME");
jPanel1.add(jLabel2);
jLabel2.setBounds(310, 500, 270, 30);
jLabel3.setFont(new java.awt.Font("Tahoma", 1, 36)); // NOI18N
jLabel3.setForeground(new java.awt.Color(255, 0, 0));
jLabel3.setText("PASSKEY");
jPanel1.add(jLabel3);
jLabel3.setBounds(310, 580, 200, 30);
txtUsername.setFont(new java.awt.Font("Tahoma", 0, 24)); // NOI18N
jPanel1.add(txtUsername);
txtUsername.setBounds(600, 490, 230, 40);
btn_logon.setBackground(new java.awt.Color(153, 255, 51));
btn_logon.setFont(new java.awt.Font("Times New Roman", 1, 24)); // NOI18N
btn_logon.setForeground(new java.awt.Color(204, 0, 0));
btn_logon.setText("LOG ON");
btn_logon.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
btn_logonActionPerformed(evt);
}
});
jPanel1.add(btn_logon);
btn_logon.setBounds(520, 690, 160, 50);
txtPasskey.setFont(new java.awt.Font("Tahoma", 0, 24)); // NOI18N
jPanel1.add(txtPasskey);
txtPasskey.setBounds(600, 570, 230, 40);
jLabel1.setIcon(new javax.swing.ImageIcon(getClass().getResource("/stark/industries/ws_Stark_Industries_1280x1024.jpg"))); // NOI18N
jPanel1.add(jLabel1);
jLabel1.setBounds(0, 0, 1210, 800);
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.PREFERRED_SIZE, 1212, javax.swing.GroupLayout.PREFERRED_SIZE)
);
layout.setVerticalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, 800, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(0, 0, 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_logonActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btn_logonActionPerformed
// TODO add your handling code here:
String username=txtUsername.getText();
String passkey = txtPasskey.getText();
ResultSet rs = null;
Statement stmt = null;
PreparedStatement pst = null;
try{
Connection con = getConnection();
stmt=con.createStatement();
String command="select * from admin where Username=? and Passkey=?";
pst=con.prepareStatement(command);
pst.setString(1, txtUsername.getText());
pst.setString(2, txtPasskey.getText());
rs=pst.executeQuery();
if(rs.next()){
JOptionPane.showMessageDialog(null, "ACCESS GRANTED! ");
JFXPanel j = new JFXPanel();
String uri = new File("Greeting.mp3").toURI().toString();
new MediaPlayer(new Media(uri)).play();
Stark_Industries_Online st = new Stark_Industries_Online();
st.setVisible(true);
Close();
}
else if(txtUsername.getText().isEmpty() || txtPasskey.getText().isEmpty()){
JOptionPane.showMessageDialog(null, "One or More Fields are EMPTY!");
}
else{
JOptionPane.showMessageDialog(null, "ACCESS DENIED!");
}
}
catch(Exception ex){
JOptionPane.showMessageDialog(null, ex.toString());
}
}//GEN-LAST:event_btn_logonActionPerformed
public void Close(){ //This Close() operation helps to close the current frame and not stop the project from running.
WindowEvent winClosingEvent = new WindowEvent(this,WindowEvent.WINDOW_CLOSING);
Toolkit.getDefaultToolkit().getSystemEventQueue().postEvent(winClosingEvent);
}
/**
* @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_HOME.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (InstantiationException ex) {
java.util.logging.Logger.getLogger(Stark_Industries_HOME.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (IllegalAccessException ex) {
java.util.logging.Logger.getLogger(Stark_Industries_HOME.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (javax.swing.UnsupportedLookAndFeelException ex) {
java.util.logging.Logger.getLogger(Stark_Industries_HOME.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_HOME().setVisible(true);
}
});
}
// Variables declaration - do not modify//GEN-BEGIN:variables
private javax.swing.JButton btn_logon;
private javax.swing.JLabel jLabel1;
private javax.swing.JLabel jLabel2;
private javax.swing.JLabel jLabel3;
private javax.swing.JPanel jPanel1;
private javax.swing.JPasswordField txtPasskey;
private javax.swing.JTextField txtUsername;
// End of variables declaration//GEN-END:variables
}