-
Notifications
You must be signed in to change notification settings - Fork 2
/
Swi3.java
62 lines (54 loc) · 1.22 KB
/
Swi3.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
/**
* @author Kireet
*
*/
import java.awt.FlowLayout;
import java.awt.event.*;
import javax.swing.*;
public class Swi3 extends JFrame implements ActionListener
{
JLabel l1= new JLabel("username");
JLabel l2= new JLabel("password");
JButton b1= new JButton("Login");
JTextField tf1= new JTextField(10);
JPasswordField tf2= new JPasswordField(10);
public Swi3()
{
add(l1);
add(tf1);
add(l2);
add(tf2);
add(b1);
setVisible(true);
setSize(400,300);
setLayout(new FlowLayout(FlowLayout.LEFT,150,10));
b1.addActionListener(this);
setDefaultCloseOperation(EXIT_ON_CLOSE);
}
@Override
public void actionPerformed(ActionEvent e)
{
// TODO Auto-generated method stub
String a= tf1.getText();
String b= tf2.getText();
if(e.getSource()==b1)
{
if(a.equals("admin")&& b.equals("pass"))
{
tf1.setText("");
tf2.setText("");
JOptionPane.showMessageDialog(this,"Successful");
}
else
{
tf1.setText("");
tf2.setText("");
JOptionPane.showMessageDialog(this,"Try again!!");
}
}
}
public static void main(String [] args)
{
Swi3 o= new Swi3();
}
}