📄 frmbook.java~144~
字号:
import java.awt.BorderLayout;
import java.awt.Dimension;
import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.JMenuBar;
import javax.swing.JToolBar;
import java.awt.*;
import javax.swing.JButton;
import javax.swing.JMenu;
import javax.swing.JMenuItem;
import javax.swing.JLabel;
import javax.swing.JSplitPane;
import javax.swing.JTree;
import javax.swing.*;
import javax.swing.border.TitledBorder;
import javax.swing.tree.DefaultMutableTreeNode;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.table.JTableHeader;
import java.awt.event.MouseEvent;
import java.awt.event.MouseAdapter;
import java.util.ArrayList;
import javax.swing.UIManager;
import java.awt.*;
import java.io.*;
import javax.swing.event.TreeSelectionEvent;
import javax.swing.event.TreeSelectionListener;
import java.awt.event.WindowEvent;
import java.awt.event.WindowAdapter;
import java.sql.ResultSet;
import java.util.Calendar;
import java.awt.event.MouseMotionAdapter;
/**
* <p>Title: </p>
*
* <p>Description: </p>
*
* <p>Copyright: Copyright (c) 2006</p>
*
* <p>Company: </p>
*
* @author not attributable
* @version 1.0
*/
public class FrmBook extends JFrame {
int page;
int totalpage=0;
JTextField txtPage;
ResultSet rstotal=null;
String table=null;
bookadd_condb baconne=new bookadd_condb(this);
clsLendNumber_condb lnconne=new clsLendNumber_condb(this);
clsLendBook_condb lbconne=new clsLendBook_condb(this);
clsLogin_condb loconne=new clsLogin_condb(this);
//static ArrayList SearchContent;//在单击表格时,保存在修改面板显示的内容
JPanel contentPane;
JMenuBar mnbBook = new JMenuBar();
JToolBar tobBook = new JToolBar();
JMenu mnuBookManage = new JMenu();
JMenuItem munBookAdd = new JMenuItem();
JLabel lblStatus = new JLabel();
JSplitPane spnH = new JSplitPane();
JTree treeBook = new JTree();
JSplitPane spnV = new JSplitPane();
JTable tblData=new JTable();
TitledBorder titledBorder1 = new TitledBorder("");
JMenuItem mnuDelete = new JMenuItem();
JMenu mnuStanUP = new JMenu();
JMenuItem mnuModify = new JMenuItem();
JMenu mnuLendManage = new JMenu();
JMenuItem mnuLendBook = new JMenuItem();
JMenuItem mnuReturnBook = new JMenuItem();
JMenu mnuLendNumberManage = new JMenu();
JMenuItem mnuLendNumberAdd = new JMenuItem();
JMenuItem mnuLendNumberDelete = new JMenuItem();
JMenu mnuLendNumberStantUp = new JMenu();
JMenuItem mnuLendNumberModify = new JMenuItem();
JMenuItem mnuLendNumberSearch = new JMenuItem();
JMenu mnuUManage = new JMenu();
JMenuItem mnuLogin = new JMenuItem();
JMenuItem mnuUAdd = new JMenuItem();
JMenuItem mnuUDelete = new JMenuItem();
JMenu mnuSearch = new JMenu();
JMenu mnuHelp = new JMenu();
JMenuItem mnuHelpDoc = new JMenuItem();
JMenu mnuSName = new JMenu();
JMenuItem mnuSJName = new JMenuItem();
JMenuItem mnuSMName = new JMenuItem();
JMenu jMenu10 = new JMenu();
JMenuItem mnuSAuthor = new JMenuItem();
JMenuItem mnuSPublish = new JMenuItem();
JMenuItem mnuSGroup = new JMenuItem();
JTableHeader jTableHeader1 = tblData.getTableHeader();
JMenuItem mnuAbout = new JMenuItem();
JMenu mnuQuit = new JMenu();
JMenuItem mnuExit = new JMenuItem();
JLabel lblStateInfo = new JLabel();
JLabel lblDate = new JLabel();
JLabel lblWeek = new JLabel();
JButton btnLogin = new JButton(new ImageIcon("pic\\sysinfo_s.gif"));
JButton btnLendBook = new JButton(new ImageIcon("pic\\time_s.gif"));
JButton btnReturnBook = new JButton(new ImageIcon("pic\\book_s.gif"));
JButton btnSearch = new JButton(new ImageIcon("pic\\Find_s.gif"));
JButton btnAbout = new JButton(new ImageIcon("pic\\Help_s.gif"));
JButton btnQuit = new JButton(new ImageIcon("pic\\Documents_s.gif"));
public FrmBook() {
try {
setDefaultCloseOperation(EXIT_ON_CLOSE);
jbInit();
this.scrollTitle(this);
this.initState();
} catch (Exception exception) {
exception.printStackTrace();
}
}
/**
* Component initialization.
*
* @throws java.lang.Exception
*/
private void jbInit() throws Exception {
contentPane = (JPanel)getContentPane();
contentPane.setLayout(null);
this.setJMenuBar(mnbBook);
setSize(new Dimension(800, 600));
setTitle("图书管理系统");
this.addWindowListener(new FrmBook_this_windowAdapter(this));
tobBook.setBounds(new Rectangle(0, 0, 800, 50));
mnuBookManage.setText("图书管理");
munBookAdd.setText("图书入库");
Color color=new Color(235,173,214);
munBookAdd.addActionListener(new FrmBook_munBookAdd_actionAdapter(this));
contentPane.setBackground(new Color(235, 208, 201));
lblStatus.setBorder(titledBorder1);
lblStatus.setText("");
lblStatus.setBounds(new Rectangle(1, 467, 800, 34));
spnH.setBounds(new Rectangle(0, 48, 800, 415));
spnH.setResizeWeight((double)0.15);
spnH.setEnabled(false);
spnH.setOneTouchExpandable(true);
spnV.setOrientation(JSplitPane.VERTICAL_SPLIT);
spnV.setResizeWeight((double)0.45);
spnV.setEnabled(false);
spnV.setOneTouchExpandable(true);
spnV.setBottomComponent(tblData);
spnV.setTopComponent(new JPanel());
spnH.setRightComponent(spnV);
mnuDelete.setText("图书报损");
UIManager.put("TextField.background",color);
mnuDelete.addActionListener(new FrmBook_mnuDelete_actionAdapter(this));
mnuLendManage.setText("借阅管理");
mnuLendBook.setText("借书");
mnuLendBook.addActionListener(new FrmBook_mnuLendBook_actionAdapter(this));
mnuReturnBook.setText("还书");
mnuReturnBook.addActionListener(new FrmBook_mnuReturnBook_actionAdapter(this));
mnuLendNumberManage.setText("借书证管理");
mnuLendNumberAdd.setText("开证");
mnuLendNumberAdd.addActionListener(new
FrmBook_mnuLendNumberAdd_actionAdapter(this));
mnuLendNumberDelete.setText("销证");
mnuLendNumberDelete.addActionListener(new
FrmBook_mnuLendNumberDelete_actionAdapter(this));
mnuLendNumberStantUp.setText("维护");
mnuLendNumberModify.setText("修改");
mnuLendNumberModify.addActionListener(new
FrmBook_mnuLendNumberModify_actionAdapter(this));
mnuLendNumberSearch.setText("查找");
mnuLendNumberSearch.addActionListener(new
FrmBook_mnuLendNumberSearch_actionAdapter(this));
mnuUManage.setText("用户管理");
mnuLogin.setText("登陆");
mnuLogin.addActionListener(new FrmBook_mnuLogin_actionAdapter(this));
mnuUAdd.setText("添加用户");
mnuUAdd.addActionListener(new FrmBook_mnuUAdd_actionAdapter(this));
mnuUDelete.setText("删除用户");
mnuUDelete.addActionListener(new FrmBook_mnuUDelete_actionAdapter(this));
mnuHelp.setText("帮助");
mnuHelpDoc.setText("帮助");
mnuHelpDoc.addActionListener(new FrmBook_mnuHelpDoc_actionAdapter(this));
mnuSName.setText("按书名");
mnuSJName.setText("精确查询");
mnuSJName.addActionListener(new FrmBook_mnuSJName_actionAdapter(this));
mnuSMName.setText("模糊查询");
mnuSMName.addActionListener(new FrmBook_mnuSMName_actionAdapter(this));
mnuSAuthor.setText("按作者");
mnuSAuthor.addActionListener(new FrmBook_mnuSAuthor_actionAdapter(this));
mnuSPublish.setText("按出版社");
mnuSPublish.addActionListener(new FrmBook_mnuSPublish_actionAdapter(this));
mnuSGroup.setText("组合查询");
mnuSGroup.addActionListener(new FrmBook_mnuSGroup_actionAdapter(this));
mnuSearch.setText("图书查询");
mnuAbout.setText("关于");
mnuAbout.addActionListener(new FrmBook_mnuAbout_actionAdapter(this));
mnuQuit.setText("退出");
mnuExit.setText("退出");
mnuExit.addActionListener(new FrmBook_mnuExit_actionAdapter(this));
tblData.addMouseListener(new FrmBook_tblData_mouseAdapter(this));
mnuModify.addActionListener(new FrmBook_mnuModify_actionAdapter(this));
mnuStanUP.setText("图书维护");
mnuModify.setText("图书修改");
lblStateInfo.setBorder(BorderFactory.createLoweredBevelBorder());
lblStateInfo.setBounds(new Rectangle(10, 471, 226, 25));
lblDate.setBorder(BorderFactory.createLoweredBevelBorder());
lblDate.setBounds(new Rectangle(247, 471, 138, 25));
lblWeek.setBorder(BorderFactory.createLoweredBevelBorder());
lblWeek.setBounds(new Rectangle(395, 471, 102, 25));
btnLogin.setToolTipText("登陆");
btnLogin.setText("");
btnLogin.addMouseMotionListener(new FrmBook_btnLogin_mouseMotionAdapter(this));
btnLogin.addMouseListener(new FrmBook_btnLogin_mouseAdapter(this));
btnLogin.addActionListener(new FrmBook_btnLogin_actionAdapter(this));
btnLendBook.setToolTipText("借书");
btnLendBook.setText("");
btnLendBook.addMouseMotionListener(new
FrmBook_btnLendBook_mouseMotionAdapter(this));
btnLendBook.addMouseListener(new FrmBook_btnLendBook_mouseAdapter(this));
btnLendBook.addActionListener(new FrmBook_btnLendBook_actionAdapter(this));
btnReturnBook.setToolTipText("还书");
btnReturnBook.setText("");
btnReturnBook.addMouseMotionListener(new
FrmBook_btnReturnBook_mouseMotionAdapter(this));
btnReturnBook.addMouseListener(new FrmBook_btnReturnBook_mouseAdapter(this));
btnReturnBook.addActionListener(new FrmBook_btnReturnBook_actionAdapter(this));
btnSearch.setToolTipText("查询");
btnSearch.setText("");
btnSearch.addMouseMotionListener(new
FrmBook_btnSearch_mouseMotionAdapter(this));
btnSearch.addMouseListener(new FrmBook_btnSearch_mouseAdapter(this));
btnSearch.addActionListener(new FrmBook_btnSearch_actionAdapter(this));
btnAbout.setToolTipText("关于");
btnAbout.setText("");
btnAbout.addMouseMotionListener(new FrmBook_btnAbout_mouseMotionAdapter(this));
btnAbout.addMouseListener(new FrmBook_btnAbout_mouseAdapter(this));
btnAbout.addActionListener(new FrmBook_btnAbout_actionAdapter(this));
btnQuit.setToolTipText("退出系统");
btnQuit.setText("");
btnQuit.addMouseListener(new FrmBook_btnQuit_mouseAdapter(this));
btnQuit.addMouseMotionListener(new FrmBook_btnQuit_mouseMotionAdapter(this));
btnQuit.addActionListener(new FrmBook_btnQuit_actionAdapter(this));
btnLogin.setSize(50,50);
btnLendBook.setSize(50,50);
btnReturnBook.setSize(50,50);
btnSearch.setSize(50,50);
btnAbout.setSize(50,50);
btnQuit.setSize(50,50);
contentPane.add(tobBook);
tobBook.add(btnLogin);
tobBook.add(btnSearch);
tobBook.add(btnReturnBook);
tobBook.add(btnLendBook);
tobBook.add(btnAbout);
tobBook.add(btnQuit);
contentPane.add(spnH);
mnbBook.add(mnuUManage);
mnbBook.add(mnuLendManage);
mnbBook.add(mnuLendNumberManage);
mnbBook.add(mnuBookManage);
mnbBook.add(mnuSearch);
mnbBook.add(mnuHelp);
mnbBook.add(mnuQuit);
mnuBookManage.add(munBookAdd);
mnuBookManage.add(mnuDelete);
mnuBookManage.add(mnuStanUP);
//spnH.add(treeBook, JSplitPane.LEFT);
spnH.add(spnV, JSplitPane.RIGHT);
contentPane.add(lblStatus);
contentPane.add(jTableHeader1);
contentPane.add(lblStateInfo);
contentPane.add(lblDate);
contentPane.add(lblWeek);
mnuStanUP.add(mnuModify);
mnuLendManage.add(mnuLendBook);
mnuLendManage.add(mnuReturnBook);
mnuLendNumberManage.add(mnuLendNumberAdd);
mnuLendNumberManage.add(mnuLendNumberDelete);
mnuLendNumberManage.add(mnuLendNumberStantUp);
mnuLendNumberStantUp.add(mnuLendNumberModify);
mnuLendNumberStantUp.add(mnuLendNumberSearch);
mnuUManage.add(mnuLogin);
mnuUManage.add(mnuUAdd);
mnuUManage.add(mnuUDelete);
mnuHelp.add(mnuHelpDoc);
mnuHelp.add(mnuAbout);
mnuSearch.add(mnuSName);
mnuSearch.add(mnuSAuthor);
mnuSearch.add(mnuSPublish);
mnuSearch.add(mnuSGroup);
mnuSName.add(mnuSJName);
mnuSName.add(mnuSMName);
mnuQuit.add(mnuExit);
mnuUAdd.setEnabled(false);
mnuUDelete.setEnabled(false);
this.mnuBookManage.setEnabled(false);
this.mnuLendManage.setEnabled(false);
this.mnuLendNumberManage.setEnabled(false);
this.btnLendBook.setEnabled(false);
this.btnReturnBook.setEnabled(false);
}
/**
* 添加工具栏的按钮
public void addToolBtn()
{
JButton btnBookAdd=new JButton(new ImageIcon("toolbtn.gif"));
JButton btnLend=new JButton(new ImageIcon("toolbtn.gif"));
JButton btnReturn=new JButton(new ImageIcon("toolbtn.gif"));
tobBook.add(btnBookAdd);
tobBook.add(btnLend);
tobBook.add(btnReturn);
}
*/
/**
* 添加树的各个节点
*/
void treeAdd()
{
DefaultMutableTreeNode root=new DefaultMutableTreeNode("图书管理系统");
String [] manage={"图书管理","借阅管理","借书证管理","用户管理","图书查询"};
String [][] detail={
{"图书入库","图书报损","图书修改",},
{"借书","还书",},
{"开证","销证","证号修改","证号查找"},
{"登陆","添加用户","删除用户"},
{"按书名精确查询","按书名模糊查询","按作者查询","按出版社查询","组合查询"}
};
for(int i=0;i<manage.length;i++)
{
DefaultMutableTreeNode parent=new DefaultMutableTreeNode(manage[i]);
for(int j=0;j<detail[i].length;j++)
{
DefaultMutableTreeNode child=new DefaultMutableTreeNode(detail[i][j]);
parent.add(child);
}
root.add(parent);
}
treeBook=new JTree(root);
JPanel pnltree=new JPanel();
pnltree.add(treeBook);
spnH.add(pnltree, JSplitPane.LEFT);
treeBook.setEnabled(false);
treeBook.addTreeSelectionListener(new
FrmBook_treeBook_treeSelectionAdapter(this));
}
/**
* 初始化状态栏
*/
public void initState()
{
Calendar c=Calendar.getInstance();
this.lblDate.setText(" "+c.get(c.YEAR)+"年"+(c.get(c.MONTH)+1)+"月"+c.get(c.DAY_OF_MONTH)+"日");
String []week={"日","一","二","三","四","五","六"};
this.lblWeek.setText(" 星期"+week[c.get(c.DAY_OF_WEEK)-1]);
}
/**
* 状态栏显示的内容
*/
public void StateContent(String SelMun,String SelMunchild)
{
this.lblStateInfo.setText("你选择了:"+SelMun+"模块中的--"+SelMunchild);
}
/**
* 数据表面板组件的添加
*/
public void DataPane(ResultSet rsto,String tab)
{
rstotal=rsto;
table=tab;
totalpage=bookadd_condb.TotalRecord(rstotal);
JScrollPane ps=new JScrollPane();
ps.setLayout(null);
ps.add(jTableHeader1);
jTableHeader1.setBounds(20,100,500,20);
ps.add(tblData);
tblData.setBounds(20,120,500,600);
JButton btnNextPage=new JButton("下一页");
JButton btnPrePage=new JButton("上一页");
JButton btnFirst=new JButton("第一页");
JButton btnLast=new JButton("最后一页");
ps.add(btnNextPage);
ps.add(btnPrePage);
ps.add(btnFirst);
ps.add(btnLast);
btnFirst.setBounds(30,5,80,50);
btnPrePage.setBounds(120,5,80,50);
btnNextPage.setBounds(210,5,80,50);
btnLast.setBounds(300,5,80,50);
btnNextPage.addActionListener(new FrmBook_btnNextPage_actionAdapter(this));
btnPrePage.addActionListener(new FrmBook_btnPrePage_actionAdapter(this));
btnFirst.addActionListener(new FrmBook_btnFirst_actionAdapter(this));
btnLast.addActionListener(new FrmBook_btnLast_actionAdapter(this));
JLabel lblGoto=new JLabel("跳到第几页:");
txtPage=new JTextField("");
JButton btnGoto=new JButton("确定");
ps.add(lblGoto);
ps.add(txtPage);
ps.add(btnGoto);
lblGoto.setBounds(30,60,70,35);
txtPage.setBounds(110,60,60,35);
btnGoto.setBounds(180,60,80,40);
btnGoto.addActionListener(new FrmBook_btnGoto_actionAdapter(this));
spnV.setBottomComponent(ps);
}
/**
* 图书入库菜单
*/
public void munBookAdd_actionPerformed(ActionEvent e) {
page=0;
pnlBookManage_add pbm=new pnlBookManage_add(this);
spnV.setTopComponent(pbm);
baconne.initSearch();
baconne.initInfo(tblData,baconne.rs);
ResultSet rsto=bookadd_condb.rsBook();
String tab="bookinfo";
this.DataPane(rsto,tab);
this.StateContent("图书管理","图书入库");
}
/**
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -