📄 loginframe1.java~61~
字号:
package logindemo;
import javax.swing.event.*;
import java.awt.*;
import com.borland.jbcl.layout.*;
import javax.swing.*;
import java.awt.event.*;
import java.sql.*;
/**
* <p>Title: </p>
*
* <p>Description: </p>
*
* <p>Copyright: Copyright (c) 2007</p>
*
* <p>Company: </p>
*
* @author not attributable
* @version 1.0
*/
//登入界面
public class LoginFrame1 extends JFrame {
JPanel contentPane;
JPanel jPanel1 = new JPanel();
JPanel jPanel2 = new JPanel();
JPanel jPanel3 = new JPanel();
JButton jButton1 = new JButton(
"<html><center><b><font color=#0000ff>图书管理员</font></html>");//图书管理员身份
JButton jButton2 = new JButton(
"<html><center><b><font color=#0000ff>读者</font></html>");//读者身份
FlowLayout flowLayout1 = new FlowLayout();
FlowLayout flowLayout2 = new FlowLayout();
JLabel jLabel1 = new JLabel("欢迎进入图书查询系统");
public LoginFrame1() {
try {
setDefaultCloseOperation(EXIT_ON_CLOSE);
jbInit();
} catch (Exception exception) {
exception.printStackTrace();
}
}
/**
* Component initialization.
*
* @throws java.lang.Exception
*/
private void jbInit() throws Exception {
contentPane = (JPanel) getContentPane();
contentPane.setLayout(flowLayout2);
setSize(new Dimension(436, 415));
setTitle("欢迎进入图书查询系统");
jPanel1.setLayout(new BoxLayout(jPanel1, BoxLayout.PAGE_AXIS));
contentPane.add(Box.createRigidArea(new Dimension(100,100)));
jLabel1.setBackground(SystemColor.control);
jLabel1.setFont(new java.awt.Font("楷体_GB2312", Font.PLAIN, 50));
jButton1.setFont(new java.awt.Font("宋体", Font.PLAIN, 20));
jButton2.setFont(new java.awt.Font("宋体", Font.PLAIN, 20));
jButton2.addActionListener(new Button2ActionListener(this));
jButton1.addActionListener(new Button1ActionListener(this));
jPanel2.setBackground(SystemColor.control);
jPanel1.setBackground(SystemColor.controlHighlight);
jPanel2.add(jButton2);
jPanel2.add(jButton1);
jPanel1.add(jLabel1);
jPanel1.add(jPanel2, null);
contentPane.add(jPanel1, null);
}
//管理员身份确认
public void showDialog() {
JDialog dialog = new JDialog(this, "登入框");
JPanel panel1 = new JPanel();
dialog.getContentPane().add(panel1);
JLabel label1 = new JLabel("请输入用户名");
panel1.add(label1);
JTextField text1 = new JTextField(30);
panel1.add(text1);
JLabel label2 = new JLabel("密码");
panel1.add(label2);
JPasswordField userPassword = new JPasswordField(20);
userPassword.setEchoChar('*');
JButton jButton3 = new JButton("登入");
jButton1.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
System.out.println("ok");
validID();
}
});
JButton jButton4 = new JButton("重置");
panel1.add(userPassword);
panel1.add(jButton3);
panel1.add(jButton4);
dialog.pack();
dialog.setModal(true);
dialog.setVisible(true);
}
void validID() {}
class Button1ActionListener implements ActionListener {
LoginFrame1 frame;
public Button1ActionListener(LoginFrame1 frame) {
this.frame = frame;
}
public void actionPerformed(ActionEvent e) {
frame.showDialog();
}
}
//读者身份进入读者主界面
class Button2ActionListener implements ActionListener {
LoginFrame1 adaptee;
Button2ActionListener(LoginFrame1 adaptee) {
this.adaptee = adaptee;
}
public void actionPerformed(ActionEvent e) {
adaptee.Button2ActionListener(e);
}
}
public void Button2ActionListener(ActionEvent e) {
try {
MainDemoframe1 Frame= new MainDemoframe1();
Frame.setVisible(true);
}
catch (Exception ew) {
System.out.println(ew.getMessage());
}
}
void loader() {
try {
MainDemoUserframe1 mainFrame = new MainDemoUserframe1();
mainFrame.setVisible(true);
} catch (Exception ew) {
System.out.println(ew.getMessage());
}
}
class ValidFailedException extends SQLException {
public ValidFailedException() {
}
public ValidFailedException(String reason) {
super(reason);
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -