📄 console.java
字号:
/* * To change this template, choose Tools | Templates * and open the template in the editor. */package libsystem;/** * * @author admin */import java.awt.*;import java.awt.event.*;import javax.swing.*;/** * 总控制台 * @author admin */public class Console extends JFrame implements ActionListener{ private JPanel panel; private JLabel title = new JLabel(); private JLabel motto2 = new JLabel(); private JLabel motto1 = new JLabel(); private JLabel motto3 = new JLabel(); private JLabel copyright = new JLabel(); private JButton addbut = new JButton(); private JButton searchbut = new JButton(); private JButton modifybut = new JButton(); private JButton deletebut = new JButton(); private JButton browsebut = new JButton(); private JButton readerbut = new JButton(); private JButton borrowbut = new JButton(); public ReaderCMD readerinfo; private BorrowCMD borrowinfo; public Console() { super("图书管理系统-Console"); InitComponent(); //初始化控件 } private void InitComponent(){ panel = new JPanel(); panel.setLayout(null); this.setBounds(0,0,1024,735); panel.setBackground(Color.black); panel.addMouseListener(new MouseAdapter(){ public void mouseClicked(MouseEvent e) { SwingUtilities.invokeLater(new Runnable() { public void run() { //安全更新 //if(readerinfo!=null&&readerinfo.isVisible())readerinfo.setVisible(false); //if(borrowinfo!=null&&borrowinfo.isVisible())borrowinfo.setVisible(false); if(readerinfo!=null)readerinfo.dispose(); if(borrowinfo!=null)borrowinfo.dispose(); } }); } }); title.setText("图书管理系统"); title.setHorizontalAlignment(JLabel.CENTER);//设置整个标签的水平对齐方式(居中) title.setFont(new Font("Dialog", 1, 50));//设置字体大小 title.setBounds(new Rectangle(300, 37, 400, 60)); title.setForeground(Color.white); title.setVisible(true); motto1.setText("Reading makes a full man"); motto1.setHorizontalAlignment(JLabel.CENTER);//设置整个标签的水平对齐方式(居中) motto1.setFont(new Font("Dialog", 1, 30));//设置字体大小 motto1.setBounds(new Rectangle(320, 250, 400, 40)); motto1.setVisible(true); motto1.setForeground(Color.white); motto2.setText("——Francis Bacon-<弗兰西斯·培根>"); motto2.setFont(new Font("Dialog", 1, 15)); motto2.setBounds(new Rectangle(430, 350, 400, 40)); motto2.setVisible(true); motto2.setForeground(Color.white); motto3.setText("读书使人完善"); motto3.setHorizontalAlignment(JLabel.CENTER);//设置整个标签的水平对齐方式(居中) motto3.setFont(new Font("Dialog", 1, 30));//设置字体大小 motto3.setBounds(new Rectangle(230, 300, 400, 40)); motto3.setVisible(true); motto3.setForeground(Color.white); copyright.setText("Kevin<Copyright: Copyright (c) 2008>"); copyright.setHorizontalAlignment(JLabel.CENTER);//设置整个标签的水平对齐方式(居中) copyright.setFont(new Font("Dialog", 1, 12));//设置字体大小 copyright.setBounds(new Rectangle(320, 650, 400, 40)); copyright.setVisible(true); copyright.setForeground(Color.white); addbut.setText("添加图书信息"); addbut.setVisible(false); addbut.setBounds(new Rectangle(250, 526, 127, 33)); addbut.addActionListener(this);//加事件监听 addbut.setForeground(Color.white); addbut.setBackground(Color.black); modifybut.setText("修改图书信息"); modifybut.setVisible(false); modifybut.setBounds(new Rectangle(430, 526, 127, 33)); modifybut.addActionListener(this);//加事件监听 modifybut.setForeground(Color.white); modifybut.setBackground(Color.black); searchbut.setText("查询图书信息"); searchbut.setVisible(false); searchbut.setBounds(new Rectangle(610, 526, 127, 33)); searchbut.addActionListener(this);//加事件监听 searchbut.setForeground(Color.white); searchbut.setBackground(Color.black); deletebut.setText("删除图书信息"); deletebut.setVisible(false); deletebut.addActionListener(this);//加事件监听 deletebut.setBounds(new Rectangle(790, 526, 127, 33)); deletebut.setForeground(Color.white); deletebut.setBackground(Color.black); browsebut.setText("浏览图书信息"); browsebut.setVisible(false); browsebut.setBounds(new Rectangle(70, 526, 127, 33)); browsebut.addActionListener(this);//加事件监听 browsebut.setForeground(Color.white); browsebut.setBackground(Color.black); readerbut.setText("读者信息管理"); readerbut.setVisible(false); readerbut.setBounds(new Rectangle(0, 0, 127, 33)); readerbut.addActionListener(this);//加事件监听 readerbut.setForeground(Color.white); readerbut.setBackground(Color.black); borrowbut.setText("借阅信息管理"); borrowbut.setVisible(false); borrowbut.setBounds(new Rectangle(897, 0, 127, 33)); borrowbut.addActionListener(this);//加事件监听 borrowbut.setForeground(Color.white); borrowbut.setBackground(Color.black); panel.add(motto1); panel.add(motto3); panel.add(copyright); panel.add(title); panel.add(motto2); panel.add(addbut); panel.add(modifybut); panel.add(searchbut); panel.add(deletebut); panel.add(browsebut); panel.add(readerbut); panel.add(borrowbut); super.add(panel); addbut.setVisible(true); modifybut.setVisible(true); searchbut.setVisible(true); deletebut.setVisible(true); browsebut.setVisible(true); readerbut.setVisible(true); borrowbut.setVisible(true); super.setVisible(true); } //共享的监听器 public void actionPerformed(ActionEvent e) { if(e.getSource()==addbut) { AddBook addinfo = new AddBook(); } else if(e.getSource()==searchbut) { SearchBook searchinfo = new SearchBook(); } else if(e.getSource()==modifybut) { ModifyBookInfo modifyinfo = new ModifyBookInfo(); } else if(e.getSource()==deletebut) { DelBook deleteinfo = new DelBook(); } else if(e.getSource()==deletebut) { DelBook deleteinfo = new DelBook(); } else if(e.getSource()==browsebut) { BrBookinfo allinfo = new BrBookinfo(); } else if(e.getSource()==readerbut) { readerinfo = new ReaderCMD(); } else if(e.getSource()==borrowbut){ borrowinfo=new BorrowCMD(); } } }
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -