⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 bookmanagermain.java

📁 java 开发的图书管理系统~~~。可以实现很多功能
💻 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 + -