import javax.swing.*;
import java.awt.event.*;
import java.awt.Color;
import java.awt.FlowLayout;
@SuppressWarnings("serial")
public class MainFrame extends JFrame implements ActionListener
{
JPanel select; //左侧的功能选择面板
JButton bookSearch, //书目检索
readerInfor, //读者信息
bookBorrowing, //书刊借阅
bookBorrowed, //借阅历史
arrearage, //违章缴款
reserve, //预约图书
reserveHistory, //预约记录
renew, //续借图书
help, //帮助信息
login, //登录系统
exit, //退出系统
changePsw, //修改密码
sureChange, //确认修改密码
canelLogin, //取消登录
canelChange, //取消修改密码
sure; //确定登录系统
String currentUser; //当前使用的用户
ShowPanel infor; //根据读者的请求查找出来的信息
boolean isLogin; //标记用户是否登入系统
JLabel warning,changeWarning; //用户名及密码
JTextField nameField;
JPasswordField psw,prePsw,newPsw,surePsw;
JDialog loginDialog,changeDialog;
JTextArea helpText;
JPanel searchPan,helpPan; //检索图书的面板
JButton search,clear; //检索面板上的检索及重置按钮
JTextField book,isbn,publisher;
JScrollPane jsp;
JPanel renewPan,reservePan; //预约及续借面板
JButton renewSure,renewCanel,reserveSure,reserveCanel;
JTextField renewIsbn,reserveIsbn;
JLabel renewInfor,reserveInfor;
public MainFrame(String frameName)
{
super(frameName);
this.setSize(950,650);
this.setLocation(30,30);
this.setBackground(Color.lightGray);
this.setLayout(null);
this.currentUser = "";
//布置左侧的功能选择按钮
select = new JPanel(new FlowLayout());
this.add(select);
select.setSize(100,700);
select.setLocation(50,70);
bookSearch = new JButton("书目检索");
bookSearch.addActionListener(this);
select.add(bookSearch);
readerInfor = new JButton("读者信息");
readerInfor.addActionListener(this);
select.add(readerInfor);
bookBorrowing = new JButton("书刊借阅");
bookBorrowing.addActionListener(this);
select.add(bookBorrowing);
bookBorrowed = new JButton("借阅历史");
bookBorrowed.addActionListener(this);
select.add(bookBorrowed);
arrearage = new JButton("违章缴费");
arrearage.addActionListener(this);
select.add(arrearage);
reserve = new JButton("预约图书");
reserve.addActionListener(this);
select.add(reserve);
reserveHistory = new JButton("预约记录");
reserveHistory.addActionListener(this);
select.add(reserveHistory);
renew = new JButton("续借图书");
renew.addActionListener(this);
select.add(renew);
changePsw = new JButton("修改密码");
changePsw.addActionListener(this);
select.add(changePsw);
help = new JButton("帮助信息");
help.addActionListener(this);
select.add(help);
login = new JButton("登录系统");
login.addActionListener(this);
select.add(login);
exit = new JButton("退出系统");
exit.addActionListener(this);
select.add(exit);
infor = new ShowPanel();
jsp = new JScrollPane(infor);
jsp.setSize(700,550);
jsp.setLocation(200,30);
this.add(jsp);
//登录对话框的设计
isLogin = false;
loginDialog = new JDialog(this,"图书馆系统登录",false);
loginDialog.setLayout(new FlowLayout());
loginDialog.setSize(200,200);
loginDialog.setLocation(400,200);
warning = new JLabel("用户名或密码错误,请重新输入");
loginDialog.add(warning);
warning.setVisible(false);
loginDialog.add(new JLabel("用户名"));
nameField = new JTextField(15);
loginDialog.add(nameField);
loginDialog.add(new JLabel("密码"));
psw = new JPasswordField(15);
loginDialog.add(psw);
sure = new JButton(" 确定 ");
sure.addActionListener(this);
loginDialog.add(sure);
canelLogin = new JButton(" 取消 ");
canelLogin.addActionListener(this);
loginDialog.add(canelLogin);
loginDialog.setDefaultCloseOperation(HIDE_ON_CLOSE);
//help面板的设计
helpPan = new JPanel();
this.add(helpPan);
helpPan.setSize(650,550);
helpPan.setLocation(200,30);
helpPan.setBackground(Color.lightGray);
helpText = new JTextArea(30,55);
helpText.setBackground(Color.lightGray);
helpText.setText("帮助面板:\n您好,欢迎使用本图书馆管理系统。您可以选择登录或者不"
+"登录系统,当您没有登录系统时,您可以根据欲检索图书的图书名、ISBN号、出版"
+"社的任意组合进行图书检索服务;当您登录到系统后"
+"可以查看自己的信息、当前的借阅情况、借阅历史、修改密码、查看违章缴费记录、"
+"也可以根据图书的ISBN来进行相应图书的续借与预约。读者的登录密码与登录帐号"
+"默认相同,均为您的学号(现在可使用0610321125)\n感谢您的使用,\n制作人:"
+"06软件工程一班-张韧\n学号-0610321125");
helpPan.add(helpText);
helpText.setLineWrap(true);
helpText.setEditable(false);
helpPan.setVisible(false);
//修改密码对话框的设计
changeDialog = new JDialog(this,"修改密码",false);
changeDialog.setLayout(new FlowLayout());
changeDialog.setSize(250,250);
changeDialog.setLocation(400,200);
changeDialog.add(new JLabel("请输入原始密码 :"));
prePsw = new JPasswordField(15);
changeDialog.add(prePsw);
changeDialog.add(new JLabel("请输入新密码 :"));
newPsw = new JPasswordField(15);
changeDialog.add(newPsw);
changeDialog.add(new JLabel("请再次输入新密码:"));
surePsw = new JPasswordField(15);
changeDialog.add(surePsw);
sureChange = new JButton(" 确定 ");
changeDialog.add(sureChange);
sureChange.addActionListener(this);
canelChange = new JButton(" 取消 ");
canelChange.addActionListener(this);
changeDialog.add(canelChange);
changeWarning = new JLabel("");
changeDialog.add(changeWarning);
changeDialog.setDefaultCloseOperation(HIDE_ON_CLOSE);
//图书检索面板
searchPan = new JPanel(new FlowLayout());
this.add(searchPan);
searchPan.setSize(350,400);
searchPan.setLocation(250,150);
searchPan.add(new JLabel(" 题名 "));
book = new JTextField(25);
searchPan.add(book);
searchPan.add(new JLabel("ISBN号"));
isbn = new JTextField(25);
searchPan.add(isbn);
searchPan.add(new JLabel("出版社"));
publisher = new JTextField(25);
searchPan.add(publisher);
search = new JButton("检索");
search.addActionListener(this);
searchPan.add(search);
clear = new JButton("重置");
clear.addActionListener(this);
searchPan.add(clear);
searchPan.setVisible(false);
//图书预约面板
reservePan = new JPanel(new FlowLayout());
this.add(reservePan);
reservePan.setSize(300,300);
reservePan.setLocation(300,150);
reservePan.add(new JLabel("欲预约图书的ISBN号"));
reserveIsbn = new JTextField(25);
reservePan.add(reserveIsbn);
reserveSure = new JButton(" 确定 ");
reserveSure.addActionListener(this);
reservePan.add(reserveSure);
reserveCanel = new JButton(" 取消 ");
reserveCanel.addActionListener(this);
reservePan.add(reserveCanel);
reserveInfor = new JLabel("");
reserveInfor.setVisible(false);
reservePan.add(reserveInfor);
reservePan.setVisible(false);
//图书续借面板
renewPan = new JPanel(new FlowLayout());
renewPan.setSize(300,300);
renewPan.setLocation(300,150);
this.add(renewPan);
renewPan.add(new JLabel("欲续借图书的ISBN编号"));
renewIsbn = new JTextField(25);
renewPan.add(renewIsbn);
renewSure = new JButton(" 确定 ");
renewSure.addActionListener(this);
renewPan.add(renewSure);
renewCanel = new JButton(" 取消 ");
renewCanel.addActionListener(this);
renewPan.add(renewCanel);
renewInfor = new JLabel("");
renewInfor.setVisible(false);
renewPan.add(renewInfor);
renewPan.setVisible(false);
this.setDefaultCloseOperation(EXIT_ON_CLOSE);
this.setVisible(true);
}
public void actionPerformed(ActionEvent e)
{
searchPan.setVisible(false);
reservePan.setVisible(false);
renewPan.setVisible(false);
jsp.setVisible(false);
helpPan.setVisible(false);
if(bookSearch == e.getSource()) //检索图书
sea