📄 interface.java
字号:
/* * To change this template, choose Tools | Templates * and open the template in the editor. */package book_booking;import java.awt.*;import java.awt.event.*;import javax.swing.*;import java.io.*;//import java.util.Hashtable;import java.sql.*;public class Interface extends JFrame implements ActionListener{ Addbooks 书籍信息录入=null; Modifybooks 书籍信息修改=null; BooksQuery 书籍信息查询=null; BookingListQuery 录入采购信息=null; Delete 删除书籍及采购=null; PrintBooking 打印采购单信息=null;// Imagecanvas canvas=null; JMenuBar bar; JMenu fileMenu; JMenuItem 录入,修改,录入采购单,查询书籍,删除信息,打印; Container con=null; CardLayout card=null; JLabel label=null; JPanel pCenter; public Interface() { // canvas=new Imagecanvas();// this.add(canvas,"Center"); 录入=new JMenuItem("录入书籍基本信息"); 修改=new JMenuItem("修改书籍基本信息"); 查询书籍=new JMenuItem("查询书籍基本信息"); 录入采购单=new JMenuItem("录入采购基本信息"); 删除信息=new JMenuItem("删除书籍及采购基本信息"); 打印=new JMenuItem("打印采购单"); bar=new JMenuBar(); fileMenu=new JMenu("菜单选项"); fileMenu.add(录入); fileMenu.add(修改); fileMenu.add(查询书籍); fileMenu.add(录入采购单); fileMenu.add(删除信息); fileMenu.add(打印); bar.add(fileMenu); setJMenuBar(bar); label=new JLabel("欢迎使用书店采购管理系统",JLabel.CENTER); label.setFont(new Font("TimesRoman",Font.BOLD,24)); label.setForeground(Color.red); 录入.addActionListener(this); 修改.addActionListener(this); 录入采购单.addActionListener(this); 查询书籍.addActionListener(this); 删除信息.addActionListener(this); 打印.addActionListener(this); card=new CardLayout(); con=getContentPane(); pCenter=new JPanel(); pCenter.setLayout(card); 书籍信息录入=new Addbooks(); 书籍信息修改=new Modifybooks(); 录入采购信息=new BookingListQuery(); 书籍信息查询=new BooksQuery(); 删除书籍及采购=new Delete(); 打印采购单信息=new PrintBooking(); pCenter.add("欢迎语界面",label); pCenter.add("录入界面",书籍信息录入); pCenter.add("修改界面",书籍信息修改); pCenter.add("查询书籍界面",书籍信息查询); pCenter.add("录入采购单界面",录入采购信息); pCenter.add("删除界面",删除书籍及采购); pCenter.add("打印界面",打印采购单信息); con.add(pCenter,BorderLayout.CENTER); con.validate(); addWindowListener(new WindowAdapter() { public void windowClosing(WindowEvent e) { System.exit(0); } }); setVisible(true); setBounds(300,200,420,380); validate(); } // @Override// public void paintComponent(Graphics g)// { // ImageIcon imageIcon = new ImageIcon(getClass().getResource("/book_booking/image/book.jpg"));// Image image = imageIcon.getImage();// // g.drawImage(image,0,0,image.getWidth(this),image.getHeight(this),this); // } public void actionPerformed(ActionEvent e) { if(e.getSource()==录入) { card.show(pCenter,"录入界面"); } else if(e.getSource()==修改) { card.show(pCenter,"修改界面"); } else if(e.getSource()==查询书籍) { card.show(pCenter,"查询书籍界面"); } else if(e.getSource()==录入采购单) { card.show(pCenter,"录入采购单界面"); } else if(e.getSource()==删除信息) { card.show(pCenter,"删除界面"); } else if(e.getSource()==打印) { card.show(pCenter,"打印界面"); } } }
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -