-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathProgram2.java
More file actions
74 lines (67 loc) · 1.71 KB
/
Program2.java
File metadata and controls
74 lines (67 loc) · 1.71 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
import javax.swing.*;
import java.awt.event.*;
public class Program2 implements ActionListener{
JFrame f;
JLabel title,username,password;
JTextField inuser;
JPasswordField inpass;
JCheckBox cb;
JButton login , reset;
Program2(){
f = new JFrame("Login page roll no 22EARCS114");
title = new JLabel("Login Page by Niraj");
username = new JLabel("User Name");
password = new JLabel("password");
inuser = new JTextField();
inpass = new JPasswordField();
cb = new JCheckBox("Show Your Password ");
login = new JButton("Login");
reset = new JButton("Reset");
title.setBounds(100,50,200,20);
inuser.setBounds(160,80,150,20);
username.setBounds(50,80,100,20);
cb.setBounds(100,150,150,20);
password.setBounds(50,120,100,20);
inpass.setBounds(160,120,150,20);
login.setBounds(100,190,80,20);
reset.setBounds(190,190,80,20);
f.add(title);
f.add(username);
f.add(password);
f.add(inuser);
f.add(inpass);
f.add(cb);
f.add(login);
f.add(reset);
f.setSize(400,400);
f.setLayout(null);
f.setVisible(true);
login.addActionListener(this);
reset.addActionListener(this);
cb.addActionListener(this);
}
public void actionPerformed(ActionEvent e) {
if( e.getSource()==login) {
if(inuser.getText().equals("niraj") && inpass.getText().equals("2004")) {
JOptionPane.showMessageDialog(f, "Login Succesfull");
}
else
JOptionPane.showMessageDialog(f, "wrong credential");
}
if (e.getSource()==reset) {
inuser.setText("");
inpass.setText("");
}
if(e.getSource()==cb) {
if(cb.isSelected()) {
inpass.setEchoChar('\u0000');
}
else {
inpass.setEchoChar('*');
}
}
}
public static void main(String[] args) {
new Program2();
}
}