📄 login.java
字号:
package pkg;
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
import java.io.*;
import java.util.*;
import java.util.regex.*;
class Login extends JFrame implements
Runnable,ActionListener {
private JLabel lbpassword = new JLabel();
private JLabel lbuser = new JLabel();
private JLabel lblog = new JLabel();
private JTextField tfuser = new JTextField();
private JPasswordField tfpassword = new JPasswordField();
private JButton btnOk = new JButton();
private Container contrainer = getContentPane();
public Login() {
super("图书信息管理系统登陆");
Thread thread=new Thread(this);
thread.start();
this.setSize(400,300);
btnOk.addActionListener(this);
this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
}
public void run(){
/*
*加载进度
*/
BookinfoDemo headDemo;
headDemo=new BookinfoDemo();
while(!headDemo.IsEnd()){
try{
Thread.sleep(100);
}
catch(InterruptedException e){
}
}//while
setVisible(true);
show();
}
public void setLayout() {
contrainer.setLayout(null);
lbuser.setText("用户名");
lbpassword.setText("密码");
lblog.setText("小型图书信息管理系统登录");
contrainer.add(lblog);
lblog.setBounds(100,40,250,20);
contrainer.add(lbuser);
lbuser.setBounds(100,90,40,20);
contrainer.add(lbpassword);
lbpassword.setBounds(100,140,40,20);
contrainer.add(tfuser);
tfuser.setBounds(150,90,100,22);
contrainer.add(tfpassword);
tfpassword.setBounds(150,140,100,22);
btnOk.setText("确定");
contrainer.add(btnOk);
btnOk.setBounds(150,200,73,25);
}
public void actionPerformed(ActionEvent e){
if(e.getActionCommand().equals("确定")){
String user = tfuser.getText();
String password = tfpassword.getText();
if(user.equals("administrator")&&password.equals("123456"))
{
BookinfoFrame frame = new BookinfoFrame();
frame.setLayout();
frame.show();
this.hide();
}
else {
String output = "请输入正确的系统登录用户名和密码!";
JOptionPane.showMessageDialog(null,output,"Message",
JOptionPane.INFORMATION_MESSAGE);
}
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -