-
Notifications
You must be signed in to change notification settings - Fork 2
/
NewLogin.java
111 lines (76 loc) · 2.92 KB
/
NewLogin.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
package canteen.management.system;
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
import java.sql.*;
public class NewLogin extends JFrame implements ActionListener{
JLabel l1,l2;
JTextField t1,t3;
JPasswordField t2;
JButton b1,b2;
NewLogin()
{
super("CONTACLESS COMPUTERIZED CANTEEN MANAGEMENT SYSTEM");
JLabel l1 = new JLabel("NEW USER");
l1.setBounds(105,20, 200, 30);
l1.setForeground(Color.BLUE);
l1.setFont(new Font ("Tahoma",Font.BOLD,20));
add(l1);
l1 = new JLabel("Username");
l1.setBounds(40 , 80 , 100 , 30 );
add(l1);
l2 = new JLabel("Password");
l2.setBounds(40 , 140 , 100 , 30 );
add(l2);
t1 = new JTextField();
t1.setBounds(150 , 80 , 150 , 30);
add(t1);
t2 = new JPasswordField();
t2.setBounds(150 , 140 , 150 , 30);
add(t2);
b1 = new JButton("Signup");
b1.setBackground(Color.RED);
b1.setForeground(Color.WHITE);
b1.setBounds(40 , 250 , 120 , 30 );
b1.addActionListener(this);
add(b1);
b2 = new JButton("Cancel");
b2.setBounds(180 , 250 , 120 , 30 );
b2.setBackground(Color.RED);
b2.setForeground(Color.WHITE);
b2.addActionListener(this);
add(b2);
ImageIcon i1 = new ImageIcon(ClassLoader.getSystemResource("canteen/management/system/icons/second.jpg "));
Image i2 = i1.getImage().getScaledInstance(200 , 200 , Image.SCALE_DEFAULT);
ImageIcon i3 = new ImageIcon(i2);
JLabel l3 = new JLabel(i3);
l3.setBounds(350 , 10 , 200 , 200 );
add(l3);
getContentPane().setBackground(Color.WHITE);
setLayout(null);
setBounds(500, 300, 800, 370);
setVisible(true);
}
public void actionPerformed(ActionEvent ae){
if(ae.getSource()==b1){
String username = t1.getText();
String password = t2.getText();
conn c = new conn();
String str = "insert into login values('"+username+"', '"+password+"')";
try
{
c.s.executeUpdate(str);
JOptionPane.showMessageDialog(null,"New user Added");
this.setVisible(false);
}catch(Exception e){
System.out.println(e);
}
}else if(ae.getSource() == b2){
new Login().setVisible(true);
this.setVisible(false);
}
}
public static void main(String[] args){
new NewLogin();
}
}