📄 mainframe.java
字号:
//主界面
import java.awt.*;
import javax.swing.*;
import javax.swing.JMenu;
import javax.swing.JMenuItem;
import java.awt.event.*;
import javax.swing.event.*;
import java.sql.*;
import java.io.*;
import java.util.*;
import java.util.Date;
import javax.swing.Timer;
import java.text.SimpleDateFormat;
import java.net.*;
import javax.swing.text.html.*;
public class MainFrame extends JFrame implements ActionListener
{private JMenuBar JMB;
private JMenu MSystem,MSBook,MBook,MReader,BookAccount,TodayInfo,MHelp,BookStock,UserMGRMenu,TjpmMenu;
public JLabel Jlb,JLb1,JLb2,JLb3,statusLB,statusLB1,statusLB2,statusLB3;
private Toolkit tool;
private Dimension wndsize;
private JButton Ok_btn,Register_btn,Cancel_btn,BggkBtn,RyzcBtn,
KgsjBtn,GcfbBtn,GnbjBtn,GzzdBtn,Xstb,Xsld,Xxfk;
private JButton btn1,btn2,btn3,btn4,btn5,btn6,btn7,btn8,btn9,btn10,btn11,btn12;
private JEditorPane tp;
private JScrollPane js;
private JTextField Jtfld1;
private JPasswordField Jtfld2;
private JComboBox JCB;
private JPanel contentPane,contentPane1,contPane,statusPane,statusPane1,statusPane2,statusPane3;
private Date nowTime;
private SimpleDateFormat matter1;
private Timer time;
private Connection con;
public JFrame frame;
public JMenuItem ExitMenuItem,ManagerItem,FajinItem,ChangeUser,HungItem,//系统管理菜单
BookTypeItem,PressItem,StockItem,//图书设置
BookInfoItem,ReaderBorrow,ReaderReturn,KeepBorrow,LookBook,//图书管理菜单
TypeSetItem,EnableZheng,ReaderInfo,LookZheng,CancelLook,XuZheng,//读者管理菜单
BookInfoF,BorrowF,ReturnF,GuaShiF,ReaderInfoF,TBorrowF,TReturnF,DandCF,//系统查询菜单
BBpm,RBpm,FKtj,//统计排名菜单
SHelp;//系统帮助菜单
public MainFrame()
{JFrame.setDefaultLookAndFeelDecorated(true);
frame=new JFrame();
Font font1=new Font("宋体",Font.PLAIN,13);
frame.setTitle("商院图书馆管理系统欢迎您!");
frame.setFont(font1);
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
ImageIcon icon=new ImageIcon("images/home.gif");
frame.setIconImage(icon.getImage());
frame.setResizable(false);
Container content=frame.getContentPane();
content.setLayout(null);
tool=frame.getToolkit();
wndsize=tool.getScreenSize();
JMB=new JMenuBar();
//--创建管理菜单--
MSystem=new JMenu("系统管理");
MSBook=new JMenu("图书设置");
MBook=new JMenu("图书管理");
MReader=new JMenu("读者管理");;
BookAccount=new JMenu("系统查询");
TodayInfo=new JMenu("今日信息查询");
TjpmMenu=new JMenu("统计排名");
MHelp=new JMenu("系统帮助");
//--设置程序初始化时各菜单无效--
MSystem.setEnabled(false);
MSBook.setEnabled(false);
MBook.setEnabled(false);
MReader.setEnabled(false);
BookAccount.setEnabled(false);
TjpmMenu.setEnabled(false);
/*********************************系统管理菜单************************************************/
//--创建系统管理菜单项--
ManagerItem=new JMenuItem("管理员设置");
FajinItem=new JMenuItem("罚金设置");
ChangeUser=new JMenuItem("切换用户");
HungItem=new JMenuItem("离开挂起");
ExitMenuItem=new JMenuItem("退出系统");
//--添加各个菜单--
MSystem.add(ManagerItem);
MSystem.add(FajinItem);
MSystem.addSeparator();
MSystem.add(ChangeUser);
MSystem.add(HungItem);
MSystem.add(ExitMenuItem);
//--设置各菜单字体--
ManagerItem.setFont(font1);
FajinItem.setFont(font1);
ChangeUser.setFont(font1);
HungItem.setFont(font1);
ExitMenuItem.setFont(font1);
MSystem.setFont(font1);
/*********************************图书设置菜单************************************************/
//--创建图书设置菜单项--
BookTypeItem=new JMenuItem("图书类型");
PressItem=new JMenuItem("出版社");
StockItem=new JMenuItem("存放位置");
//--添加各个菜单--
MSBook.add(BookTypeItem);
MSBook.addSeparator();
MSBook.add(PressItem);
MSBook.addSeparator();
MSBook.add(StockItem);
//--设置各菜单字体--
MSBook.setFont(font1);
BookTypeItem.setFont(font1);
PressItem.setFont(font1);
StockItem.setFont(font1);
/*********************************图书管理菜单************************************************/
//--创建图书管理菜单项--
BookInfoItem=new JMenuItem("图书资料");
ReaderBorrow=new JMenuItem("借阅图书");
KeepBorrow=new JMenuItem("续借图书");
ReaderReturn=new JMenuItem("归还图书");
LookBook=new JMenuItem("挂失图书");
//--创建图书管理菜单项--
MBook.add(BookInfoItem);
MBook.addSeparator();
MBook.add(ReaderBorrow);
MBook.add(KeepBorrow);
MBook.add(ReaderReturn);
MBook.addSeparator();
MBook.add(LookBook);
//--设置各个菜单字体--
MBook.setFont(font1);
BookInfoItem.setFont(font1);
ReaderBorrow.setFont(font1);
KeepBorrow.setFont(font1);
ReaderReturn.setFont(font1);
LookBook.setFont(font1);
/*********************************读者管理菜单************************************************/
//--创建读者管理菜单项--
TypeSetItem=new JMenuItem("类型设置");
EnableZheng=new JMenuItem("有效证件");
ReaderInfo=new JMenuItem("读者信息");
LookZheng=new JMenuItem("读者挂失");
CancelLook=new JMenuItem("解除挂失");
XuZheng=new JMenuItem("到期续证");
//--添加各个菜单--
MReader.add(TypeSetItem);
MReader.add(EnableZheng);
MReader.addSeparator();
MReader.add(ReaderInfo);
MReader.add(LookZheng);
MReader.add(CancelLook);
MReader.addSeparator();
MReader.add(XuZheng);
//--设置各菜单字体--
MReader.setFont(font1);
TypeSetItem.setFont(font1);
EnableZheng.setFont(font1);
ReaderInfo.setFont(font1);
LookZheng.setFont(font1);
CancelLook.setFont(font1);
XuZheng.setFont(font1);
/*********************************系统查询菜单************************************************/
//--创建统计查询管理菜单项--
BookInfoF=new JMenuItem("图书信息查询");
BorrowF=new JMenuItem("借阅图书查询");
ReturnF=new JMenuItem("归还/超期图书查询");
GuaShiF=new JMenuItem("挂失图书查询");
ReaderInfoF=new JMenuItem("读者信息查询");
TBorrowF=new JMenuItem("借阅图书信息");
TReturnF=new JMenuItem("归还图书信息");
DandCF=new JMenuItem("到期/超期信息");
//--添加各个菜单--
BookAccount.add(BookInfoF);
BookAccount.add(BorrowF);
BookAccount.add(ReturnF);
BookAccount.add(GuaShiF);
BookAccount.add(ReaderInfoF);
BookAccount.addSeparator();
TodayInfo.add(TBorrowF);
TodayInfo.add(TReturnF);
TodayInfo.add(DandCF);
BookAccount.add(TodayInfo);
//--设置各菜单字体--
BookAccount.setFont(font1);
TodayInfo.setFont(font1);
BookInfoF.setFont(font1);
BorrowF.setFont(font1);
ReturnF.setFont(font1);
GuaShiF.setFont(font1);
ReaderInfoF.setFont(font1);
TBorrowF.setFont(font1);
TReturnF.setFont(font1);
DandCF.setFont(font1);
/*********************************统计排名菜单************************************************/
//--创建统计查询管理菜单项--
BBpm=new JMenuItem("图书借阅排名");
RBpm=new JMenuItem("读者借阅排名");
FKtj=new JMenuItem("罚款统计");
//--添加各个菜单--
TjpmMenu.add(BBpm);
TjpmMenu.add(RBpm);
TjpmMenu.add(FKtj);
//--设置各菜单字体--
BBpm.setFont(font1);
RBpm.setFont(font1);
FKtj.setFont(font1);
TjpmMenu.setFont(font1);
/*********************************系统帮助菜单************************************************/
//--创建系统帮助菜单项--
SHelp=new JMenuItem("系统帮助");
//--添加各个菜单--
MHelp.add(SHelp);
//--设置各菜单字体--
MHelp.setFont(font1);
SHelp.setFont(font1);
/*********************************设置各菜单项事件************************************************/
ManagerItem.addActionListener(this);
FajinItem.addActionListener(this);
ChangeUser.addActionListener(this);
HungItem.addActionListener(this);
ExitMenuItem.addActionListener(this);
BookTypeItem.addActionListener(this);
PressItem.addActionListener(this);
StockItem.addActionListener(this);
BookInfoItem.addActionListener(this);
ReaderBorrow.addActionListener(this);
KeepBorrow.addActionListener(this);
ReaderReturn.addActionListener(this);
LookBook.addActionListener(this);
TypeSetItem.addActionListener(this);
EnableZheng.addActionListener(this);
ReaderInfo.addActionListener(this);
LookZheng.addActionListener(this);
CancelLook.addActionListener(this);
XuZheng.addActionListener(this);
BookInfoF.addActionListener(this);
BorrowF.addActionListener(this);
ReturnF.addActionListener(this);
GuaShiF.addActionListener(this);
ReaderInfoF.addActionListener(this);
TBorrowF.addActionListener(this);
TReturnF.addActionListener(this);
DandCF.addActionListener(this);
BBpm.addActionListener(this);
RBpm.addActionListener(this);
FKtj.addActionListener(this);
SHelp.addActionListener(this);
//--添加管理菜单--
JMB.add(MSystem);
JMB.add(MSBook);
JMB.add(MBook);
JMB.add(MReader);
JMB.add(BookAccount);
JMB.add(TjpmMenu);
JMB.add(MHelp);
frame.setJMenuBar(JMB);
/*********************************创建工具菜单************************************************/
//--创建工具菜单条--
JToolBar JTB=new JToolBar();
btn1=new JButton(new ImageIcon("images/cc.gif"));
btn2=new JButton(new ImageIcon("images/reader.gif"));
btn3=new JButton(new ImageIcon("images/text2.gif"));
btn4=new JButton(new ImageIcon("images/findd.gif"));
btn5=new JButton(new ImageIcon("images/fnis.gif"));
btn6=new JButton(new ImageIcon("images/BOOKS01.gif"));
btn7=new JButton(new ImageIcon("images/book1.gif"));
btn8=new JButton(new ImageIcon("images/findddds.gif"));
btn9=new JButton(new ImageIcon("images/find2.gif"));
btn10=new JButton(new ImageIcon("images/card.gif"));
btn11=new JButton(new ImageIcon("images/close1.gif"));
btn12=new JButton(new ImageIcon("images/help3.gif"));
//--为各工具菜单增加提示功能--
btn1.setToolTipText("注销当前用户");
btn2.setToolTipText("读者资料维护");
btn3.setToolTipText("借阅记录");
btn4.setToolTipText("浏览书目");
btn5.setToolTipText("检索书目");
btn6.setToolTipText("图书资料管理");
btn7.setToolTipText("借阅图书管理");
btn8.setToolTipText("续借图书管理");
btn9.setToolTipText("归还图书管理");
btn10.setToolTipText("读者挂失、解除挂失与到期续证管理");
btn11.setToolTipText("图书挂失管理");
btn12.setToolTipText("系统帮助");
//为各个按钮设置事件
btn1.addActionListener(this);
btn2.addActionListener(this);
btn3.addActionListener(this);
btn4.addActionListener(this);
btn5.addActionListener(this);
btn6.addActionListener(this);
btn7.addActionListener(this);
btn8.addActionListener(this);
btn9.addActionListener(this);
btn10.addActionListener(this);
btn11.addActionListener(this);
btn12.addActionListener(this);
//--添加各个工具菜单--
JTB.addSeparator();
JTB.addSeparator();
JTB.add(btn1);
JTB.addSeparator();
JTB.add(btn2);
JTB.add(btn10);
JTB.addSeparator();
JTB.add(btn6);
JTB.add(btn3);
JTB.add(btn7);
JTB.add(btn8);
JTB.add(btn9);
JTB.add(btn11);
JTB.addSeparator();
JTB.add(btn4);
JTB.add(btn5);
JTB.addSeparator();
JTB.add(btn12);
JTB.setFloatable(false);
JTB.setBorder(BorderFactory.createLoweredBevelBorder());
JTB.setBounds(0,2,tool.getScreenSize().width-10,45);
/*********************************创建登录、注册区域************************************************/
//--创建登录区--
contentPane=new JPanel();
contentPane.setLayout(null);
//--初始化各个组件--
String[] s={"图书馆管理员","教师","学生"};
JLb1=new JLabel("用 户 名:");
JLb2=new JLabel("密 码:");
JLb3=new JLabel("请选择身份:");
Jtfld1=new JTextField(10);
Jtfld2=new JPasswordField(10);
JCB=new JComboBox(s);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -