-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathNew_Password_Page.java
More file actions
248 lines (225 loc) · 13.4 KB
/
Copy pathNew_Password_Page.java
File metadata and controls
248 lines (225 loc) · 13.4 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
import java.sql.*;
import javax.swing.*;
import java.awt.*;
/*
* 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.
*/
/**
*
* @author root
*/
public class New_Password_Page extends javax.swing.JFrame {
String url="jdbc:mysql://localhost:3306/"; //sizde 3306 olabilir
String veritabaniadi="passbox_db"; // ulaşmak istediğiniz veri tabanı ismi
String surucu="com.mysql.jdbc.Driver";
String kullaniciAdi="root"; // workbench deki kullanıcı adınız ne ise o "root" olabilir
String kullaniciParolası=""; //workbench deki şifreniz ne ise o
Connection baglanti=null;
Statement komut=null;
ResultSet gelenveri=null;
PreparedStatement pst=null;
/**
* Creates new form Manage_Passwords_Page
*/
public New_Password_Page() {
initComponents();
setIcon();
setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);
try {
Class.forName(surucu);
//baglantı veri tabanı seçimi kullanıcı adı ve parola ile sağlanı
baglanti= DriverManager.getConnection(url+veritabaniadi, kullaniciAdi,kullaniciParolası);
} catch (ClassNotFoundException | SQLException ex) {
System.out.println("HATA 1: Surucu ve baglantı hatsı !"+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() {
jLabel_socail_media_name = new javax.swing.JLabel();
jLabel_username = new javax.swing.JLabel();
jLabel_password = new javax.swing.JLabel();
socail_media_name_txt = new javax.swing.JTextField();
username_txt = new javax.swing.JTextField();
password_txt = new javax.swing.JTextField();
jButton1 = new javax.swing.JButton();
jLabel_email_address = new javax.swing.JLabel();
email_address_txt = new javax.swing.JTextField();
jButton2 = new javax.swing.JButton();
jButton_TurnBack = new javax.swing.JButton();
setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE);
setTitle("PassBox | New Add Password ");
setResizable(false);
jLabel_socail_media_name.setFont(new java.awt.Font("Tahoma", 1, 11)); // NOI18N
jLabel_socail_media_name.setText("Social Media Name : ");
jLabel_username.setFont(new java.awt.Font("Tahoma", 1, 11)); // NOI18N
jLabel_username.setText("Username : ");
jLabel_password.setFont(new java.awt.Font("Tahoma", 1, 11)); // NOI18N
jLabel_password.setText("Password : ");
socail_media_name_txt.setFont(new java.awt.Font("Tahoma", 1, 11)); // NOI18N
username_txt.setFont(new java.awt.Font("Tahoma", 1, 11)); // NOI18N
password_txt.setFont(new java.awt.Font("Tahoma", 1, 11)); // NOI18N
jButton1.setFont(new java.awt.Font("Tahoma", 1, 11)); // NOI18N
jButton1.setIcon(new javax.swing.ImageIcon(getClass().getResource("/ico/add_new_password_ico.png"))); // NOI18N
jButton1.setText("New Password Add");
jButton1.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
jButton1.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
jButton1.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton1ActionPerformed(evt);
}
});
jLabel_email_address.setFont(new java.awt.Font("Tahoma", 1, 11)); // NOI18N
jLabel_email_address.setText("E-Mail Address : ");
email_address_txt.setFont(new java.awt.Font("Tahoma", 1, 11)); // NOI18N
jButton2.setIcon(new javax.swing.ImageIcon(getClass().getResource("/logo/PassBox.png"))); // NOI18N
jButton_TurnBack.setFont(new java.awt.Font("Tahoma", 1, 11)); // NOI18N
jButton_TurnBack.setIcon(new javax.swing.ImageIcon(getClass().getResource("/ico/turnback_ico.png"))); // NOI18N
jButton_TurnBack.setText("Turn Back");
jButton_TurnBack.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
jButton_TurnBack.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
jButton_TurnBack.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
jButton_TurnBackActionPerformed(evt);
}
});
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
getContentPane().setLayout(layout);
layout.setHorizontalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addContainerGap()
.addComponent(jButton2, javax.swing.GroupLayout.PREFERRED_SIZE, 320, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
.addComponent(jLabel_socail_media_name)
.addComponent(jLabel_username)
.addComponent(jLabel_password)
.addComponent(jLabel_email_address))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
.addComponent(password_txt, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, 205, Short.MAX_VALUE)
.addComponent(socail_media_name_txt, javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(username_txt, javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(email_address_txt, javax.swing.GroupLayout.Alignment.LEADING)))
.addGroup(layout.createSequentialGroup()
.addGap(6, 6, 6)
.addComponent(jButton_TurnBack, javax.swing.GroupLayout.PREFERRED_SIZE, 151, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addComponent(jButton1, javax.swing.GroupLayout.DEFAULT_SIZE, 166, Short.MAX_VALUE)))
.addContainerGap())
);
layout.setVerticalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
.addComponent(jButton2)
.addContainerGap())
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jLabel_socail_media_name)
.addComponent(socail_media_name_txt, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(username_txt, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jLabel_username))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(password_txt, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jLabel_password))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jLabel_email_address)
.addComponent(email_address_txt, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGap(67, 67, 67)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
.addComponent(jButton_TurnBack, javax.swing.GroupLayout.DEFAULT_SIZE, 90, Short.MAX_VALUE)
.addComponent(jButton1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
.addGap(11, 11, 11))))
);
pack();
}// </editor-fold>//GEN-END:initComponents
private void jButton_TurnBackActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton_TurnBackActionPerformed
// TODO add your handling code here:
this.setVisible(false);
}//GEN-LAST:event_jButton_TurnBackActionPerformed
private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton1ActionPerformed
// TODO add your handling code here:
String sorgu = "INSERT INTO `passbox_db`.`password_database_tb`(`account_name`,`username`,`password`,`email_address`)VALUES(?,?,?,?)";
try {
pst=baglanti.prepareStatement(sorgu);
pst.setString(1, socail_media_name_txt.getText());
pst.setString(2, username_txt.getText());
pst.setString(3, password_txt.getText());
pst.setString(4, email_address_txt.getText());
int x= pst.executeUpdate();
if(x==1)
JOptionPane.showMessageDialog(null,"Başarılı Kayıt");
else
JOptionPane.showMessageDialog(null,"Başarısız Kayıt");
} catch (SQLException ex) {
JOptionPane.showConfirmDialog(null, "Sorgu da hata var !"+ex);
}
}//GEN-LAST:event_jButton1ActionPerformed
/**
* @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(New_Password_Page.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (InstantiationException ex) {
java.util.logging.Logger.getLogger(New_Password_Page.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (IllegalAccessException ex) {
java.util.logging.Logger.getLogger(New_Password_Page.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
} catch (javax.swing.UnsupportedLookAndFeelException ex) {
java.util.logging.Logger.getLogger(New_Password_Page.class.getName()).log(java.util.logging.Level.SEVERE, null, ex);
}
//</editor-fold>
//</editor-fold>
/* Create and display the form */
java.awt.EventQueue.invokeLater(new Runnable() {
public void run() {
new New_Password_Page().setVisible(true);
}
});
}
// Variables declaration - do not modify//GEN-BEGIN:variables
private javax.swing.JTextField email_address_txt;
private javax.swing.JButton jButton1;
private javax.swing.JButton jButton2;
private javax.swing.JButton jButton_TurnBack;
private javax.swing.JLabel jLabel_email_address;
private javax.swing.JLabel jLabel_password;
private javax.swing.JLabel jLabel_socail_media_name;
private javax.swing.JLabel jLabel_username;
private javax.swing.JTextField password_txt;
private javax.swing.JTextField socail_media_name_txt;
private javax.swing.JTextField username_txt;
// End of variables declaration//GEN-END:variables
private void setIcon() {
setIconImage(Toolkit.getDefaultToolkit().getImage(getClass().getResource("passbox_ico.png")));
}
}