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

📄 book_main.java

📁 图书馆管理系统 用swing界面做的一个图书馆管理系统 里面有增删改等功能 适合初学者看看
💻 JAVA
字号:
//主控制窗口
import java.awt.*;
import java.awt.event.*;
import javax.swing.*;

public class book_main extends JFrame implements ActionListener{
	JMenuBar mb = new JMenuBar();
	
	JMenu m_refer=new JMenu("图书检索");
	JMenu m_update=new JMenu("图书更新");
	JMenu m_else=new JMenu("其他服务");
	
	JMenuItem mi_demand=new JMenuItem("图书查询");
	
	JMenuItem mi_append=new JMenuItem("图书添加");
	JMenuItem mi_update=new JMenuItem("图书更新");
	JMenuItem mi_delete=new JMenuItem("图书删除");
	
	JMenuItem mi_exit=new JMenuItem("退出系统");
	
	JToolBar tool = new JToolBar();
	
	JButton b_demand = new JButton(new ImageIcon("imgs/search.png"));
	JButton b_append= new JButton(new ImageIcon("imgs/input.png"));
	JButton b_update= new JButton(new ImageIcon("imgs/update.jpg"));
	JButton b_delete= new JButton(new ImageIcon("imgs/delete.png"));
	
	JButton b_exit = new JButton(new ImageIcon("imgs/exit.jpg"));
	
	JLabel l_imgs = new JLabel(new ImageIcon("imgs/img.jpg"));
	
	//Panel p=new Panel();
	Container c = this.getContentPane();
	public book_main(){
		super("我的图书馆管理系统");
		
		this.buildBarMenu();//主题栏
		this.setJMenuBar(mb);
		
		this.buildToolMenu();//图画按钮 
		c.add(tool,BorderLayout.NORTH);
		c.add(l_imgs,BorderLayout.CENTER);
				
		this.setBounds(300,100,800,600);
    	this.setVisible(true);    	
    	this.validate();
    	
    	this.setResizable(false);
    	
    	//给菜单注册监听器
    	mi_demand.addActionListener(this);
    	mi_append.addActionListener(this);
    	mi_update.addActionListener(this);
    	mi_delete.addActionListener(this);
    	mi_exit.addActionListener(this);
    	
    	//为图标注册监听器
    	b_demand.addActionListener(this);
    	b_append.addActionListener(this);
    	b_update.addActionListener(this);
    	b_delete.addActionListener(this);
    	b_exit.addActionListener(this);
	}
	//标题栏
	void buildBarMenu(){
		
		mb.add(m_refer);
		mb.add(m_update);
		mb.add(m_else);
		
		m_refer.add(mi_demand);
		
		m_update.add(mi_append);
		m_update.add(mi_update);
		m_update.add(mi_delete);
		
		m_else.add(mi_exit);
		
	}
	//图片栏
	void buildToolMenu(){
		
		tool.setFloatable(false);//不能移动工具栏
		
		tool.add(b_demand);
		tool.addSeparator();
		
		tool.add(b_append);
		tool.add(b_update);
		tool.add(b_delete);
		tool.addSeparator();
		
		tool.add(b_exit);
	}
	public void actionPerformed(ActionEvent e){
		if(e.getSource()==b_exit||e.getSource()==mi_exit){
			new book_login();
			this.dispose();
		}
		if(e.getSource()==mi_demand||e.getSource()==b_demand){
			new book_demand();//进入查询页面
			this.dispose();
		}
		if(e.getSource()==mi_append||e.getSource()==b_append){
			new book_append();//进入添加页面
			this.dispose();
		}
		if(e.getSource()==mi_delete||e.getSource()==b_delete){
			new book_delete();//进入删除页面
			this.dispose(); 
		}
		if(e.getSource()==mi_update||e.getSource()==b_update){
			new book_update();
			this.dispose();
		}
	}//跳转页面
	//
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -