-
Notifications
You must be signed in to change notification settings - Fork 0
/
LOGIN.java
68 lines (68 loc) · 1.99 KB
/
LOGIN.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
import java.awt.*;
import MAIn.*;
import java.awt.event.*;
import javax.swing.*;
import java.util.*;
public class LOGIN extends JFrame implements ActionListener {
JPanel panel;
JLabel user_label, password_label, message;
JTextField userName_text;
String Username;
String Password;
JPasswordField password_text;
JButton submit, cancel;
JFrame frame;
public void signup()
{
System.out.println("Enter the username");
Scanner sc = new Scanner(System.in);
Username=sc.nextLine();
System.out.println("Enter the password");
Scanner sp = new Scanner(System.in);
Password=sp.nextLine();
}
public void DLoginDemo() {
// Username Label
user_label = new JLabel();
user_label.setText("User Name :");
userName_text = new JTextField();
// Password Label
password_label = new JLabel();
password_label.setText("Password :");
password_text = new JPasswordField();
// Submit
submit = new JButton("SUBMIT");
panel = new JPanel(new GridLayout(3, 1));
panel.add(user_label);
panel.add(userName_text);
panel.add(password_label);
panel.add(password_text);
message = new JLabel();
panel.add(message);
panel.add(submit);
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
submit.addActionListener(this);
add(panel, BorderLayout.CENTER);
setTitle("Please Login Here !");
setSize(450,350);
setVisible(true);
}
public static void main(String[] args) {
LOGIN p = new LOGIN();
p.signup();
p.DLoginDemo();
}
@Override
public void actionPerformed(ActionEvent ae) {
String userName = userName_text.getText();
String password = password_text.getText();
if (userName.trim().equals(Username) && password.trim().equals(Password)) {
message.setText(" Hello " + userName + "");
dispose();
MAIn G = new MAIn();
G.main(null);
} else {
message.setText(" Invalid user.. ");
}
}
}