📄 frmlibrary.java
字号:
package 毕业设计;
import java.awt.BorderLayout;
import java.awt.Dimension;
import javax.swing.ImageIcon;
import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.JMenuBar;
import javax.swing.JMenu;
import javax.swing.JMenuItem;
import java.awt.*;
import javax.swing.JButton;
import com.borland.jbcl.layout.XYLayout;
import com.borland.jbcl.layout.*;
import javax.swing.JLabel;
import java.awt.event.ComponentEvent;
import java.awt.event.ComponentAdapter;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
public class frmLibrary extends JFrame {
JPanel contentPane;
JMenuBar mnbMenuBar = new JMenuBar();
JMenu mnuUser = new JMenu();
JMenuItem mnuUpdatePassword = new JMenuItem();
JMenuItem mnuLogout = new JMenuItem();
JMenu mnuUserManage = new JMenu();
JMenuItem mnuUserAdd = new JMenuItem();
JMenuItem mnuUserUpdate = new JMenuItem();
JMenu mnuLibrary = new JMenu();
JMenuItem mnuInto = new JMenuItem();
JMenuItem mnuLibUpdate = new JMenuItem();
JMenu mnuReader = new JMenu();
JMenuItem mnuReaAdd = new JMenuItem();
JMenuItem mnuReaUpdate = new JMenuItem();
JMenu mnuHelp = new JMenu();
JMenuItem mnuAbout = new JMenuItem();
JMenuItem mnuReaFind = new JMenuItem();
JMenuItem mnuLibFind = new JMenuItem();
JPanel jPanel1 = new JPanel();
JButton btnLoan = new JButton(new ImageIcon("Map\\借书.gif"));
JButton btnAbout = new JButton(new ImageIcon("Map\\关于.gif"));
JButton btnExit = new JButton(new ImageIcon("Map\\退出.gif"));
JButton btnUpdatePassword = new JButton(new ImageIcon("Map\\修改密码.gif"));
JButton btnLibSearch = new JButton(new ImageIcon("Map\\图书查询.gif"));
JButton btnReturn = new JButton(new ImageIcon("Map\\还书.gif"));
JButton btnReaSearch = new JButton(new ImageIcon("Map\\读者查询.gif"));
JButton btnLibArray = new JButton(new ImageIcon("Map\\读者排名.gif"));
JButton btnReaArray = new JButton(new ImageIcon("Map\\图书排名.gif"));
GridLayout gridLayout1 = new GridLayout();
JMenuItem mnuFind = new JMenuItem();
JMenu mnuDateSet = new JMenu();
JMenuItem mnuSortSet = new JMenuItem();
JMenuItem mnuPublishSet = new JMenuItem();
JMenuItem mnuVocationSet = new JMenuItem();
JMenu mnuStat = new JMenu();
JMenuItem mnuAutArray = new JMenuItem();
JMenuItem mnuLibArray = new JMenuItem();
JMenuItem mnuLoan = new JMenuItem();
JMenuItem mnuReturn = new JMenuItem();
JMenuItem jMenuItem1 = new JMenuItem();
JLabel lblMap = new JLabel();
JMenuItem mnuRecord = new JMenuItem();
public frmLibrary() {
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(null);
this.setJMenuBar(mnbMenuBar);
setSize(new Dimension(800, 600));
setTitle("图书管理系统");
mnuUser.setFont(new java.awt.Font("宋体", Font.PLAIN, 13));
mnuUser.setText("【用户管理】");
mnuUpdatePassword.setText("修改密码");
mnuUpdatePassword.addActionListener(new
frmLibrary_mnuUpdatePassword_actionAdapter(this));
mnuLogout.setText("注 销");
mnuLogout.addActionListener(new frmLibrary_mnuLogout_actionAdapter(this));
mnuUserManage.setText("管理用户");
mnuUserAdd.setText("添 加");
mnuUserAdd.addActionListener(new frmLibrary_mnuUserAdd_actionAdapter(this));
mnuUserUpdate.setText("维 护");
mnuUserUpdate.addActionListener(new
frmLibrary_mnuUserUpdate_actionAdapter(this));
mnuLibrary.setFont(new java.awt.Font("宋体", Font.PLAIN, 13));
mnuLibrary.setText("【图书管理】");
mnuInto.setText("新书入库");
mnuInto.addActionListener(new frmLibrary_mnuInto_actionAdapter(this));
mnuLibUpdate.setText("图书维护");
mnuLibUpdate.addActionListener(new
frmLibrary_mnuLibUpdate_actionAdapter(this));
mnuReader.setFont(new java.awt.Font("宋体", Font.PLAIN, 13));
mnuReader.setText("【读者管理】");
mnuReaAdd.setText("添 加");
mnuReaAdd.addActionListener(new frmLibrary_mnuReaAdd_actionAdapter(this));
mnuReaUpdate.setText("维 护");
mnuReaUpdate.addActionListener(new
frmLibrary_mnuReaUpdate_actionAdapter(this));
mnuHelp.setFont(new java.awt.Font("宋体", Font.PLAIN, 13));
mnuHelp.setText("【帮 助】");
mnuAbout.setText("关 于");
mnuAbout.addActionListener(new frmLibrary_mnuAbout_actionAdapter(this));
mnuReaFind.setText("查 询");
mnuReaFind.addActionListener(new frmLibrary_mnuReaFind_actionAdapter(this));
mnuLibFind.setText("图书查询");
mnuLibFind.addActionListener(new frmLibrary_mnuLibFind_actionAdapter(this));
jPanel1.setBounds(new Rectangle(1, 1, 596, 56));
jPanel1.setLayout(gridLayout1);
btnLoan.setText("");
btnLoan.addActionListener(new frmLibrary_btnloan_actionAdapter(this));
btnAbout.setText("");
btnAbout.addActionListener(new frmLibrary_btnAbout_actionAdapter(this));
btnExit.setText("");
btnExit.addActionListener(new frmLibrary_btnExit_actionAdapter(this));
btnUpdatePassword.setToolTipText("");
btnUpdatePassword.setText("");
btnUpdatePassword.addActionListener(new
frmLibrary_btnUpdatePassword_actionAdapter(this));
btnLibSearch.setText("");
btnLibSearch.addActionListener(new frmLibrary_btnLibFind_actionAdapter(this));
btnReturn.setText("");
btnReturn.addActionListener(new frmLibrary_btnReturn_actionAdapter(this));
mnuFind.setText("查 询");
mnuFind.addActionListener(new frmLibrary_mnuFind_actionAdapter(this));
mnuDateSet.setFont(new java.awt.Font("宋体", Font.PLAIN, 13));
mnuDateSet.setText("【设 置】");
mnuSortSet.setText("图书类别设置");
mnuSortSet.addActionListener(new frmLibrary_mnuSortSet_actionAdapter(this));
mnuPublishSet.setText("出版社设置");
mnuPublishSet.addActionListener(new
frmLibrary_mnuPublishSet_actionAdapter(this));
mnuVocationSet.setText("读者职业设置");
mnuVocationSet.addActionListener(new
frmLibrary_mnuVocationSet_actionAdapter(this));
mnuStat.setFont(new java.awt.Font("宋体", Font.PLAIN, 13));
mnuStat.setText("【统 计】");
mnuAutArray.setText("读者排名");
mnuAutArray.addActionListener(new frmLibrary_mnuAutArray_actionAdapter(this));
mnuLibArray.setText("图书排名");
mnuLibArray.addActionListener(new frmLibrary_mnuLibArray_actionAdapter(this));
mnuLoan.setText("借 书");
mnuLoan.addActionListener(new frmLibrary_mnuLoan_actionAdapter(this));
mnuReturn.setText("还 书");
mnuReturn.addActionListener(new frmLibrary_mnuReturn_actionAdapter(this));
jMenuItem1.setText("退 出");
jMenuItem1.addActionListener(new frmLibrary_jMenuItem1_actionAdapter(this));
lblMap.setText("");
lblMap.setBounds(new Rectangle( -1, 57, 800, 541));
lblMap.setIcon(new ImageIcon("Map\\背景.jpg"));
contentPane.addComponentListener(new
frmLibrary_contentPane_componentAdapter(this));
btnReaSearch.setText("");
btnReaSearch.addActionListener(new
frmLibrary_btnReaSearch_actionAdapter(this));
btnLibArray.setText("");
btnLibArray.addActionListener(new frmLibrary_btnLibArray_actionAdapter(this));
btnReaArray.setText("");
btnReaArray.addActionListener(new frmLibrary_btnReaArray_actionAdapter(this));
mnuRecord.setText("过期未还记录");
mnuRecord.addActionListener(new frmLibrary_mnuRecord_actionAdapter(this));
mnbMenuBar.add(mnuUser);
mnbMenuBar.add(mnuLibrary);
mnbMenuBar.add(mnuReader);
mnbMenuBar.add(mnuDateSet);
mnbMenuBar.add(mnuStat);
mnbMenuBar.add(mnuHelp);
mnuUser.add(mnuUpdatePassword);
mnuUser.add(mnuUserManage);
mnuUser.add(mnuLogout);
mnuUser.addSeparator();
mnuUser.add(jMenuItem1);
mnuUserManage.add(mnuUserAdd);
mnuUserManage.add(mnuFind);
mnuUserManage.add(mnuUserUpdate);
mnuLibrary.add(mnuInto);
mnuLibrary.add(mnuLoan);
mnuLibrary.add(mnuReturn);
mnuLibrary.addSeparator();
mnuLibrary.add(mnuLibFind);
mnuLibrary.addSeparator();
mnuLibrary.add(mnuLibUpdate);
mnuReader.add(mnuReaAdd);
mnuReader.add(mnuReaFind);
mnuReader.add(mnuReaUpdate);
mnuHelp.add(mnuAbout);
jPanel1.add(btnLoan, null);
jPanel1.add(btnReturn, null);
jPanel1.add(btnLibSearch, null);
jPanel1.add(btnReaSearch, null);
jPanel1.add(btnReaArray, null);
jPanel1.add(btnLibArray, null);
jPanel1.add(btnUpdatePassword, null);
jPanel1.add(btnAbout, null);
jPanel1.add(btnExit, null);
contentPane.add(lblMap);
contentPane.add(jPanel1);
mnuDateSet.add(mnuPublishSet);
mnuDateSet.add(mnuSortSet);
mnuDateSet.addSeparator();
mnuDateSet.add(mnuVocationSet);
mnuStat.add(mnuLibArray);
mnuStat.add(mnuAutArray);
mnuStat.addSeparator();
mnuStat.add(mnuRecord);
setmnuEnabled();
}
//***************************权限设置***********************************
public void setmnuEnabled() {
UserConDB userDB = new UserConDB();
String popedom;
popedom = userDB.SearchUsing().getPopedom().toString();
userDB.CloseUserDB();
if (popedom.equals("Super")) {
mnuUserManage.setEnabled(true);
mnuDateSet.setEnabled(true);
mnuReader.setEnabled(true);
mnuLoan.setEnabled(true);
mnuReturn.setEnabled(true);
mnuLibUpdate.setEnabled(true);
mnuInto.setEnabled(true);
btnReturn.setEnabled(true);
btnReaSearch.setEnabled(true);
btnLoan.setEnabled(true);
mnuAutArray.setEnabled(true);
btnLibArray.setEnabled(true);
} else if (popedom.equals("Admin")) {
mnuUserManage.setEnabled(false);
mnuDateSet.setEnabled(false);
mnuReader.setEnabled(true);
mnuLoan.setEnabled(true);
mnuReturn.setEnabled(true);
mnuLibUpdate.setEnabled(true);
mnuInto.setEnabled(true);
btnReturn.setEnabled(true);
btnReaSearch.setEnabled(true);
btnLoan.setEnabled(true);
mnuAutArray.setEnabled(true);
btnLibArray.setEnabled(true);
} else {
mnuReader.setEnabled(false);
mnuUserManage.setEnabled(false);
mnuDateSet.setEnabled(false);
mnuLoan.setEnabled(false);
mnuReturn.setEnabled(false);
mnuLibUpdate.setEnabled(false);
mnuInto.setEnabled(false);
btnReturn.setEnabled(false);
btnReaSearch.setEnabled(false);
btnLoan.setEnabled(false);
mnuAutArray.setEnabled(false);
btnLibArray.setEnabled(false);
}
}
//******************************显示窗口********************************
public void ShowfrmMain() {
Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize();
Dimension dlgSize = this.getSize();
if (dlgSize.height > screenSize.height) {
dlgSize.height = screenSize.height;
}
if (dlgSize.width > screenSize.width) {
dlgSize.width = screenSize.width;
}
this.setLocation((screenSize.width - dlgSize.width) / 2,
(screenSize.height - dlgSize.height) / 2);
this.setVisible(true);
}
//****************************图片根随窗口改变**********************************
public void contentPane_componentResized(ComponentEvent e) {
lblMap.setSize(this.getWidth(), this.getHeight() - 100);
}
//****************************图书添加**********************************
public void mnuInto_actionPerformed(ActionEvent e) {
dlgLibAdd libAdd = new dlgLibAdd();
libAdd.ShowLibAdd();
}
//*****************************读者添加*********************************
public void mnuReaAdd_actionPerformed(ActionEvent e) {
dlgReaAdd reaAdd = new dlgReaAdd();
reaAdd.ShowReaAdd();
}
//*****************************用户添加*********************************
public void mnuUserAdd_actionPerformed(ActionEvent e) {
dlgUserAdd userAdd = new dlgUserAdd();
userAdd.ShowUserAdd();
}
//*****************************借书按钮事件*********************************
public void btnloan_actionPerformed(ActionEvent e) {
dlgLoanBook loanBook = new dlgLoanBook();
loanBook.ShowLoanBook();
}
//******************************借书菜单********************************
public void mnuLoan_actionPerformed(ActionEvent e) {
dlgLoanBook loanBook = new dlgLoanBook();
loanBook.ShowLoanBook();
}
//******************************更新密码********************************
public void mnuUpdatePassword_actionPerformed(ActionEvent e) {
dlgUpdatePassword updatePassword = new dlgUpdatePassword();
updatePassword.ShowUpdatePassw();
}
//*******************************还书按钮事件*******************************
public void btnReturn_actionPerformed(ActionEvent e) {
dlgReturnBook returnBook = new dlgReturnBook();
returnBook.ShowReturnBook();
}
//*****************************还书菜单*********************************
public void mnuReturn_actionPerformed(ActionEvent e) {
dlgReturnBook returnBook = new dlgReturnBook();
returnBook.ShowReturnBook();
}
//*****************************图书查询按钮事件*********************************
public void btnLibSearch_actionPerformed(ActionEvent e) {
frmLibSearch libSearch = new frmLibSearch();
libSearch.ShowLibSearch();
}
//*****************************图书查询菜单*********************************
public void mnuFind_actionPerformed(ActionEvent e) {
frmUserSearch userSearch = new frmUserSearch();
userSearch.ShowUserSearch();
}
//*****************************关于按钮事件*********************************
public void btnAbout_actionPerformed(ActionEvent e) {
dlgAbout about = new dlgAbout();
about.ShowAbout();
}
//******************************关于菜单********************************
public void mnuAbout_actionPerformed(ActionEvent e) {
dlgAbout about = new dlgAbout();
about.ShowAbout();
}
//*******************************注销*******************************
public void mnuLogout_actionPerformed(ActionEvent e) {
dlgLogout logout = new dlgLogout();
logout.ShowLogout();
setmnuEnabled();
}
//******************************更新密码********************************
public void btnUpdatePassword_actionPerformed(ActionEvent e) {
dlgUpdatePassword updatePassword = new dlgUpdatePassword();
updatePassword.ShowUpdatePassw();
}
//******************************退出菜单********************************
public void jMenuItem1_actionPerformed(ActionEvent e) {
System.exit(0);
}
//******************************用户更新********************************
public void mnuUserUpdate_actionPerformed(ActionEvent e) {
frmUserUpdate userupdate = new frmUserUpdate();
userupdate.ShowUserUpdate();
}
//******************************读者查询菜单********************************
public void mnuReaFind_actionPerformed(ActionEvent e) {
frmReaSearch readersearch = new frmReaSearch();
readersearch.ShowReaSearch();
}
//******************************读者查询按钮事件********************************
public void btnReaSearch_actionPerformed(ActionEvent e) {
frmReaSearch readersearch = new frmReaSearch();
readersearch.ShowReaSearch();
}
//******************************读者更新********************************
public void mnuReaUpdate_actionPerformed(ActionEvent e) {
frmReaUpdate readerUpdate = new frmReaUpdate();
readerUpdate.ShowReaUpdate();
}
//*****************************图书查询菜单*********************************
public void mnuLibFind_actionPerformed(ActionEvent e) {
frmLibSearch libSearch = new frmLibSearch();
libSearch.ShowLibSearch();
}
//*****************************图书更新*********************************
public void mnuLibUpdate_actionPerformed(ActionEvent e) {
frmLibManage libManage = new frmLibManage();
libManage.ShowLibManage();
}
//*****************************图书出版社设置*********************************
public void mnuPublishSet_actionPerformed(ActionEvent e) {
dlgPublish publish = new dlgPublish();
publish.ShowPublish();
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -