Repository navigation
Expand file tree
/
Copy path.Main-code-1
More file actions
105 lines (93 loc) · 3.39 KB
/
Copy path.Main-code-1
File metadata and controls
105 lines (93 loc) · 3.39 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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
/*
Project.No:26(Batch.No:13),
Implement a GUI based java program which should have a login page and should take in ID and
password as login credentials. Then it should display all the notes that were previously saved
by the user. It should give him the option to delete previous notes and also add new notes.
*/
package PRJT_26;
import javax.imageio.ImageIO;
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
import java.awt.event.ActionListener;
import java.awt.image.BufferedImage;
import java.awt.image.ImageObserver;
import java.io.File;
import java.io.*;
import java.io.IOException;
import javax.swing.plaf.metal.*;
import javax.swing.text.*;
public class M2_LOGIN implements ActionListener{
private static final long serialVersionUID = 1L;
private static JLabel label1,label2,label3;
private static JTextField username;
private static JButton button1,button2;
private static JPasswordField password;
private static ImageIcon img;
public static void main(String args[]) throws IOException {
JPanel panel=new JPanel();
panel.setLayout(null);
panel.setBackground(Color.white);
JFrame frame=new JFrame() ;
frame.setTitle("LOGIN PAGE");
frame.setLocation(new Point(500,200));
frame.add(panel);
frame.setSize(new Dimension(500,400));
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
File file = new File("C:\\Users\\Hello\\eclipse-workspace\\Project_No_26\\12345678.jpg");
BufferedImage bufferedImage = ImageIO.read(file);
ImageIcon imageIcon = new ImageIcon(bufferedImage);
label3=new JLabel(imageIcon);
label3.setBounds(50,0,400,200);
panel.add(label3);
label1=new JLabel("<html><font color='black'>Username</font></html>");
label1.setBackground(Color.BLUE);
label1.setBounds(150,190,70,20);
panel.add(label1);
username = new JTextField();
username.setBounds(150,209,193,28);
panel.add(username);
label2= new JLabel("<html><font color='black'>Password</font></html>");
label2.setBounds(150,237,70,20);
panel.add(label2);
password=new JPasswordField();
password.setBounds(150,256,193,28);
panel.add(password);
button1 = new JButton("Login");
button1.setBounds(150,295,90,25);
button1.setForeground(Color.WHITE);
button1.setBackground(Color.BLACK);
button1.addActionListener((ActionListener) new M2_LOGIN());
panel.add(button1);
button2 = new JButton("Reset");
button2.setBounds(250,295,90,25);
button2.setForeground(Color.WHITE);
button2.setBackground(Color.BLACK);
button2.addActionListener((ActionListener) new M2_LOGIN());
panel.add(button2);
frame.setVisible(true);
}
public void actionPerformed(ActionEvent e) {
JFrame frame=new JFrame() ;
frame.setLocation(new Point(500, 300));
frame.setSize(new Dimension(400, 200));
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
if(e.getSource()==button2) {
username.setText("");
password.setText("");
}
if(e.getSource()==button1) {
String u= username.getText();
String p = String.valueOf(password.getPassword());
if(u.equals("kluniversity")&&p.equals("java#15")) {
M3_NOTES notes=new M3_NOTES();
JOptionPane.showMessageDialog(null,"Login Succsesful...");
username.setText("");
password.setText("");
}
else {
JOptionPane.showMessageDialog(null," Wrong Username or Password ");
}
}
}
}