package library;
import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Font;
import java.awt.GridBagLayout;
import java.awt.GridLayout;
import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.PasswordAuthentication; import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;
import javax.swing.AbstractButton; import javax.swing.JButton;
import javax.swing.JComboBox;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JOptionPane; import javax.swing.JPanel;
import javax.swing.JPasswordField; import javax.swing.JRadioButton;
import javax.swing.JTextField;
public class login extends JFrame implements ActionListener { private JTextField namefield;
private JTextField numfield;
private JButton button;
private String number;
private AbstractButton button1;
private JComboBox box;
public login() {
init();
}
private void init() {
setDefaultCloseOperation(EXIT_ON_CLOSE);
setBounds(200, 200, 450, 400);
setResizable(false);
setLayout(null);
setTitle("登录界面");
JLabel label = new JLabel("欢迎使用图书管理系统!");
label.setFont(new Font("宋体", Font.BOLD, 18));
add(label);
label.setBounds(150, 5, 200, 200); JLabel label2 = new JLabel("账号");
add(label2);
label2.setBounds(150, 150, 100, 100); namefield = new JTextField(); namefield.setBounds(200, 190, 100, 20); add(namefield);
JLabel label3 = new JLabel("密码");
add(label3);
label3.setBounds(150, 180, 100, 100); numfield = new JPasswordField();
add(numfield);
numfield.setBounds(200, 220, 100, 20); JLabel label4 = new JLabel("选择身份"); add(label4);
label4.setBounds(130, 210, 100, 100); box = new JComboBox();
box.addItem("管理员");
box.addItem("学生");
add(box);
box.setBounds(200, 250, 100, 20);
button = new JButton("登录");
add(button);
button.setBounds(80, 300, 80, 25);
button.addActionListener(this);
button1 = new JButton("退出");
add(button1);
button1.setBounds(300, 300, 100, 25);
button1.addActionListener(this);
}
public static void main(String[] args) {
new login().setVisible(true);
}
@Override
public void actionPerformed(ActionEvent e) { Object source = e.getSource();
if (SelectedItem().equals("管理员"))
{ if (source == button)
{
if ((Text().trim().equals("8899") ) && (Text().trim().equals("1234")))
{
this.dispose();
new manager().setVisible(true);
}
}
}
if ((SelectedItem().equals("学生")))
{ if (source == button){
DbUtil util = Util();
try {
Statement stat = Statement();
基于java的图书管理系统
String name = Text().trim();
ResultSet rs = stat
.executeQuery("select stu_code from student where stu_name="

版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系QQ:729038198,我们将在24小时内删除。