-
Notifications
You must be signed in to change notification settings - Fork 0
/
LoginPage.java
75 lines (75 loc) · 1.55 KB
/
LoginPage.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
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
public class LoginPage implements ActionListener
{
String password="1234";
String username="athul";
JButton b,r;
JTextField t,t2;
JPasswordField pf;
JLabel l1,l2,l3;
LoginPage()
{
JFrame f=new JFrame("Login Page ");
JPanel p=new JPanel();
b=new JButton("LOGIN");
b.setBounds(200,150,200,30);
r=new JButton("RESET");
r.setBounds(200,200,200,30);
l1=new JLabel("UserName");
t=new JTextField();
t.setBounds(200,50,200,30);
l1.setBounds(100,50,200,30);
l2=new JLabel("Password");
l2.setBounds(100,100,200,30);
pf=new JPasswordField();
pf.setBounds(200,100,200,30);
//t2=new JTextField();
//t2.setBounds(200,100,200,30);
l3=new JLabel();
l3.setBounds(230,300,200,30);
p.add(b);
p.add(r);
p.add(t);
//p.add(t2);
p.add(pf);
p.add(l1);
p.add(l2);
p.add(l3);
b.addActionListener(this);
r.addActionListener(this);
f.setContentPane(p);
f.setSize(500,400);
f.setLayout(null);
f.setVisible(true);
}
public void actionPerformed(ActionEvent e) {
if(e.getSource()==b)
{
char[] st=pf.getPassword();
String str=String.valueOf(st);
//String s=t2.getText();
String usrnme=t.getText();
if(str.equals(password)&&usrnme.equals(username))
{
l3.setText(".....Welcome User.....");
}
else
{
l3.setText("Invalid Username or password!!!!!");
}
}
if(e.getSource()==r)
{
t.setText("");
//t2.setText("");
pf.setText("");
l3.setText("");
}
}
public static void main(String[] args)
{
new LoginPage();
}
}