?? bookmanagermain.java
字號:
package bookmanager;
import javax.swing.*;
import javax.swing.event.*;
import java.awt.event.*;
import java.awt.Point;
import java.awt.Dimension;
public class BookManagerMain extends JFrame
{
public BookManagerMain()
{
this.addWindowListener(new WindowListener(){
public void windowActivated(WindowEvent e){}
public void windowClosed(WindowEvent e){}
public void windowClosing(WindowEvent e){}
public void windowDeactivated(WindowEvent e){}
public void windowDeiconified(WindowEvent e){}
public void windowIconified(WindowEvent e){}
public void windowOpened(WindowEvent e){
BookManagerMain.this.setEnabled("else");
userLogin dlg=new userLogin(BookManagerMain.this);
Dimension dlgSize=dlg.getPreferredSize();
Dimension frmSize=BookManagerMain.this.getSize();
Point loc=BookManagerMain.this.getLocation();
dlg.setLocation((frmSize.width-dlgSize.width)/2+loc.x,(frmSize.height-dlgSize.height)/2+loc.y);
dlg.pack();
dlg.show();
}
});
this.setTitle("書籍管理系統");
bar=new JMenuBar();
setJMenuBar(bar);
muSystem=new JMenu("系統管理");
muBookManager=new JMenu("書籍管理");
muBookManager.setFocusPainted(true);
muBorrowBook=new JMenu("借書管理");
muBorrowBook.setFocusPainted(true);
muReturnBook=new JMenu("還書管理");
muReturnBook.setFocusPainted(true);
muAllInfo=new JMenu("信息一覽");
muAllInfo.setFocusPainted(true);
muUserManager=new JMenu("用戶管理");
miLogin=new JMenuItem("用戶登錄");
miUserAdd=new JMenuItem("添加用戶");
miUserEdit=new JMenuItem("修改用戶");
miUserDel=new JMenuItem("刪除用戶");
miExit=new JMenuItem("退出");
miBookAdd=new JMenuItem("添加書籍信息");
miBookEdit=new JMenuItem("修改書籍信息");
miBookDel=new JMenuItem("刪除書籍信息");
miBookBorrow=new JMenuItem("書籍出借");
miBookBorrowUpdate=new JMenuItem("出借信息管理");
miBookReturn=new JMenuItem("書籍還入");
miBookReturnUpdate=new JMenuItem("書籍還入信息修改");
miAllBook=new JMenuItem("書籍列表");
miAllReader=new JMenuItem("借閱者列表");
miAllInfo=new JMenuItem("借閱情況列表");
bar.add(muSystem);
bar.add(muBookManager);
bar.add(muBorrowBook);
bar.add(muReturnBook);
bar.add(muAllInfo);
muSystem.add(muUserManager);
muUserManager.add(miLogin);
muUserManager.add(miUserAdd);
muUserManager.add(miUserEdit);
muUserManager.add(miUserDel);
muSystem.add(miExit);
miExit.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent e)
{
System.exit(0);
}
}
);
muBookManager.add(miBookAdd);
muBookManager.add(miBookEdit);
muBookManager.add(miBookDel);
muBorrowBook.add(miBookBorrow);
muBorrowBook.add(miBookBorrowUpdate);
muReturnBook.add(miBookReturn);
muReturnBook.add(miBookReturnUpdate);
muAllInfo.add(miAllBook);
muAllInfo.add(miAllReader);
muAllInfo.add(miAllInfo);
setJMenuBar(bar);
miLogin.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent e){
userLogin dlg=new userLogin(BookManagerMain.this);
Dimension dlgSize=dlg.getPreferredSize();
Dimension frmSize=BookManagerMain.this.getSize();
Point loc=BookManagerMain.this.getLocation();
dlg.setLocation((frmSize.width-dlgSize.width)/2+loc.x,(frmSize.height-dlgSize.height)/2+loc.y);
dlg.pack();
dlg.show();
}
});
miUserAdd.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent e){
userAdd dlg=new userAdd();
Dimension dlgSize=dlg.getPreferredSize();
Dimension frmSize=BookManagerMain.this.getSize();
Point loc=BookManagerMain.this.getLocation();
dlg.setLocation((frmSize.width-dlgSize.width)/2+loc.x,(frmSize.height-dlgSize.height)/2+loc.y);
dlg.pack();
dlg.show();
}
});
miUserEdit.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent e){
userEdit dlg=new userEdit();
Dimension dlgSize=dlg.getPreferredSize();
Dimension frmSize=BookManagerMain.this.getSize();
Point loc=BookManagerMain.this.getLocation();
dlg.setLocation((frmSize.width-dlgSize.width)/2+loc.x,(frmSize.height-dlgSize.height)/2+loc.y);
dlg.pack();
dlg.show();
}
});
miUserDel.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent e){
userDel dlg=new userDel();
Dimension dlgSize=dlg.getPreferredSize();
Dimension frmSize=BookManagerMain.this.getSize();
Point loc=BookManagerMain.this.getLocation();
dlg.setLocation((frmSize.width-dlgSize.width)/2+loc.x,(frmSize.height-dlgSize.height)/2+loc.y);
dlg.pack();
dlg.show();
}
});
miBookAdd.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent e){
BookAdd dlg=new BookAdd();
Dimension dlgSize=dlg.getPreferredSize();
Dimension frmSize=BookManagerMain.this.getSize();
Point loc=BookManagerMain.this.getLocation();
dlg.setLocation((frmSize.width-dlgSize.width)/2+loc.x,(frmSize.height-dlgSize.height)/2+loc.y);
dlg.pack();
dlg.show();
}
});
miBookEdit.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent e){
BookEdit dlg=new BookEdit();
Dimension dlgSize=dlg.getPreferredSize();
Dimension frmSize=BookManagerMain.this.getSize();
Point loc=BookManagerMain.this.getLocation();
dlg.setLocation((frmSize.width-dlgSize.width)/2+loc.x,(frmSize.height-dlgSize.height)/2+loc.y);
dlg.pack();
dlg.show();
}
});
miBookDel.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent e){
BookDel dlg=new BookDel();
Dimension dlgSize=dlg.getPreferredSize();
Dimension frmSize=BookManagerMain.this.getSize();
Point loc=BookManagerMain.this.getLocation();
dlg.setLocation((frmSize.width-dlgSize.width)/2+loc.x,(frmSize.height-dlgSize.height)/2+loc.y);
dlg.pack();
dlg.show();
}
});
miBookBorrow.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent e){
BookBorrow dlg=new BookBorrow();
Dimension dlgSize=dlg.getPreferredSize();
Dimension frmSize=BookManagerMain.this.getSize();
Point loc=BookManagerMain.this.getLocation();
dlg.setLocation((frmSize.width-dlgSize.width)/2+loc.x,(frmSize.height-dlgSize.height)/2+loc.y);
dlg.pack();
dlg.show();
}
});
miBookBorrowUpdate.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent e){
BookBorrowUpdate dlg=new BookBorrowUpdate();
Dimension dlgSize=dlg.getPreferredSize();
Dimension frmSize=BookManagerMain.this.getSize();
Point loc=BookManagerMain.this.getLocation();
dlg.setLocation((frmSize.width-dlgSize.width)/2+loc.x,(frmSize.height-dlgSize.height)/2+loc.y);
dlg.pack();
dlg.show();
}
});
miBookReturn.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent e){
BookReturn dlg=new BookReturn();
Dimension dlgSize=dlg.getPreferredSize();
Dimension frmSize=BookManagerMain.this.getSize();
Point loc=BookManagerMain.this.getLocation();
dlg.setLocation((frmSize.width-dlgSize.width)/2+loc.x,(frmSize.height-dlgSize.height)/2+loc.y);
dlg.pack();
dlg.show();
}
});
miBookReturnUpdate.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent e){
BookReturnUpdate dlg=new BookReturnUpdate();
Dimension dlgSize=dlg.getPreferredSize();
Dimension frmSize=BookManagerMain.this.getSize();
Point loc=BookManagerMain.this.getLocation();
dlg.setLocation((frmSize.width-dlgSize.width)/2+loc.x,(frmSize.height-dlgSize.height)/2+loc.y);
dlg.pack();
dlg.show();
}
});
miAllBook.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent e){
AllBook dlg=new AllBook();
Dimension dlgSize=dlg.getPreferredSize();
Dimension frmSize=BookManagerMain.this.getSize();
Point loc=BookManagerMain.this.getLocation();
dlg.setLocation((frmSize.width-dlgSize.width)/2+loc.x,(frmSize.height-dlgSize.height)/2+loc.y);
dlg.pack();
dlg.show();
}
});
miAllReader.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent e){
AllReader dlg=new AllReader();
Dimension dlgSize=dlg.getPreferredSize();
Dimension frmSize=BookManagerMain.this.getSize();
Point loc=BookManagerMain.this.getLocation();
dlg.setLocation((frmSize.width-dlgSize.width)/2+loc.x,(frmSize.height-dlgSize.height)/2+loc.y);
dlg.pack();
dlg.show();
}
});
miAllInfo.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent e){
AllInfo dlg=new AllInfo();
Dimension dlgSize=dlg.getPreferredSize();
Dimension frmSize=BookManagerMain.this.getSize();
Point loc=BookManagerMain.this.getLocation();
dlg.setLocation((frmSize.width-dlgSize.width)/2+loc.x,(frmSize.height-dlgSize.height)/2+loc.y);
dlg.pack();
dlg.show();
}
});
}
public void setEnabled(String powertype){
if(powertype.equals("管理員"))
{
muUserManager.setEnabled(true);
miLogin.setEnabled(true);
miUserAdd.setEnabled(true);
miUserEdit.setEnabled(true);
miUserDel.setEnabled(true);
muBookManager.setEnabled(true);
muBorrowBook.setEnabled(true);
muReturnBook.setEnabled(true);
muAllInfo.setEnabled(true);
}
else if(powertype.equals("書籍管理員"))
{
muUserManager.setEnabled(false);
muBookManager.setEnabled(true);
muBorrowBook.setEnabled(false);
muReturnBook.setEnabled(false);
muAllInfo.setEnabled(true);
}
else if(powertype.equals("借閱操作員"))
{
muUserManager.setEnabled(false);
muBookManager.setEnabled(false);
muBorrowBook.setEnabled(true);
muReturnBook.setEnabled(true);
muAllInfo.setEnabled(true);
}
else
{
muUserManager.setEnabled(true);
miLogin.setEnabled(true);
miUserAdd.setEnabled(false);
miUserEdit.setEnabled(false);
miUserDel.setEnabled(false);
muBookManager.setEnabled(false);
muBorrowBook.setEnabled(false);
muReturnBook.setEnabled(false);
muAllInfo.setEnabled(false);
}
}
private JMenuBar bar;
private JMenu muSystem;
private JMenu muBookManager;
private JMenu muBorrowBook;
private JMenu muReturnBook;
private JMenu muAllInfo;
private JMenu muUserManager;
private JMenuItem miLogin;
private JMenuItem miUserAdd;
private JMenuItem miUserEdit;
private JMenuItem miUserDel;
private JMenuItem miExit;
private JMenuItem miBookAdd;
private JMenuItem miBookEdit;
private JMenuItem miBookDel;
private JMenuItem miBookBorrow;
private JMenuItem miBookBorrowUpdate;
private JMenuItem miBookReturn;
private JMenuItem miBookReturnUpdate;
private JMenuItem miAllBook;
private JMenuItem miAllReader;
private JMenuItem miAllInfo;
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -