-
Notifications
You must be signed in to change notification settings - Fork 10
Expand file tree
/
Copy pathLesson4.java
More file actions
55 lines (44 loc) · 1.24 KB
/
Copy pathLesson4.java
File metadata and controls
55 lines (44 loc) · 1.24 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
package test;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.JPasswordField;
import javax.swing.JTextField;
public class LogIn extends JFrame{
public LogIn(){
JPanel panel = new JPanel();
JLabel label = new JLabel("ID : ");
JLabel pswrd = new JLabel("Password : ");
JTextField txtID = new JTextField(10);
JPasswordField txtPass = new JPasswordField(10);
JButton logBtn = new JButton("Log In");
panel.add(label);
panel.add(txtID);
panel.add(pswrd);
panel.add(txtPass);
panel.add(logBtn);
logBtn.addActionListener(new ActionListener(){
@Override
public void actionPerformed(ActionEvent e) {
String id = "Dan";
String pass = "1234";
if(id.equals(txtID.getText())&&pass.equals(txtPass.getText())){
JOptionPane.showMessageDialog(null, "You have logged in Successfully!");
}
}
});
add(panel);
setVisible(true);
setSize(600,400);
setLocationRelativeTo(null);
setResizable(false);
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
}
public static void main(String[] args) {
new LogIn();
}
}