-
Notifications
You must be signed in to change notification settings - Fork 0
/
Main.java
99 lines (89 loc) · 2.63 KB
/
Main.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
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
import java.awt.*;
import javax.swing.*;
import java.awt.event.*;
public class Main implements ActionListener{
static database obj;
JFrame jf;
JPanel jp;
JLabel wel,user,pass;
JTextField username;
JPasswordField password;
JButton login,exit;
Main()
{
obj=new database("jdbc:mysql://localhost:3306/stdatabase","root","gautum1234");
wel=new JLabel("<html>Welcome To Library Management<br> Start by Admin Login<html>", null, 0);
user=new JLabel("Username : ", null, 0);
pass=new JLabel("Password : ", null, 0);
username=new JTextField(50);
password=new JPasswordField(50);
password.setEchoChar('*');
login=new JButton("LOG IN", null);
exit=new JButton("EXIT", null);
jp=new JPanel(new GridBagLayout(), false);
jf=new JFrame("Library Management System - Admin Login", null);
login.addActionListener(this);
exit.addActionListener(this);
GridBagConstraints gbc = new GridBagConstraints();
gbc.fill = GridBagConstraints.BOTH;
gbc.insets = new Insets(5, 5, 5, 5);
gbc.ipadx = 50;
gbc.ipady = 30;
gbc.gridx = 0;
gbc.gridy = 0;
gbc.gridwidth = 2;
jp.add(wel, gbc);
gbc.gridy = 1;
gbc.gridwidth = 1;
jp.add(user, gbc);
gbc.gridx = 1;
jp.add(username, gbc);
gbc.gridx = 0;
gbc.gridy = 2;
jp.add(pass, gbc);
gbc.gridx = 1;
jp.add(password, gbc);
gbc.gridx=0;
gbc.gridy = 3;
jp.add(exit, gbc);
gbc.gridx=1;
gbc.gridy = 3;
jp.add(login, gbc);
jf.add(jp);
jf.setVisible(true);
jf.setSize(900, 500);
jf.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
}
public void actionPerformed(ActionEvent ae)
{
String s=ae.getActionCommand();
if(s=="LOG IN")
{
String ret=obj.adm_login(username.getText(), new String(password.getPassword()));
if(ret==null)
{
login.setText("TRY AGAIN");
exit.setText("Admin Not Found!!!");
}
else
{
new MainCell(ret);
}
}
else if(s=="TRY AGAIN")
{
login.setText("LOG IN");
exit.setText("EXIT");
}
else
System.exit(0);
}
public static void main(String[] args) {
SwingUtilities.invokeLater(new Runnable() {
public void run()
{
new Main();
}
});
}
}