-
Notifications
You must be signed in to change notification settings - Fork 0
/
code17.java
50 lines (41 loc) · 1.27 KB
/
code17.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
import java.awt.*;
import java.awt.event.*;
public class code17 extends Frame implements ActionListener {
TextField nameField, passField, resultField;
Label lab1, lab2;
Button b;
code17() {
setLayout(new GridLayout(4, 2, 0, 10));
setBackground(Color.PINK);
nameField = new TextField(15);
passField = new TextField(15);
resultField = new TextField(15);
lab1 = new Label("Enter User Name");
lab2 = new Label("Enter Password");
b = new Button("Enter");
b.addActionListener(this);
passField.setEchoChar('*');
resultField.setEditable(true);
add(lab1);
add(nameField);
add(lab2);
add(passField);
add(b);
add(resultField);
setTitle("User Name & Password Validation");
setSize(300, 300);
setVisible(true);
}
public void actionPerformed(ActionEvent e) {
String str1 = nameField.getText();
String str2 = passField.getText();
if (str1.equals("kamakshi") && str2.equals("ojha")) {
resultField.setText("VALID");
} else {
resultField.setText("INVALID, TRY AGAIN");
}
}
public static void main(String[] args) {
code17 obj = new code17();
}
}