import java.awt.event.*;
import java.awt.*;
import java.sql.*;
import javax.swing.border.*;
import javax.swing.*;
public class windows extends JFrame implements ActionListener{
JMenuBar menubar;
JMenu menu,searchMenu,delMenu,insertMenu,modifyMenu;
JMenuItem consumerItem1,bookItem1,goodsItem1,inforItem1,consumerItem2,bookItem2,goodsItem2,inforItem2,consumerItem3,bookItem3,goodsItem3,inforItem3,consumerItem4,bookItem4,goodsItem4,inforItem4;
JMenuItem printItem1,printItem2,printItem3, printItem4;
JMenuItem proItem1, proItem2, proItem3, proItem4;
JMenuItem exitItem;
private final ImageIcon myimage=new ImageIcon("4.jpg");//背景图片
private final Image image=myimage.getImage();
private JPanel Panel = new JPanel()
{
private static final long serialVersionUID = 1L;
public void paintComponent(Graphics g)
{
g.drawImage(image, 0, 0,this.getWidth(),this.getHeight(),null);
}
};//重写paintComponent
windows(String s)
{
setTitle(s);
setSize(600,400);
setLocation(200,200);
setVisible(true);
menubar = new JMenuBar();
menu = new JMenu("其他操作");
searchMenu = new JMenu("查询");
delMenu = new JMenu("删除");
insertMenu = new JMenu("登记");
modifyMenu = new JMenu("修改");
consumerItem1 = new JMenuItem("顾客信息");
bookItem1 = new JMenuItem("订单信息");
goodsItem1 = new JMenuItem("库存商品信息");
inforItem1 = new JMenuItem("订单详细信息");
consumerItem2 = new JMenuItem("顾客信息");
bookItem2 = new JMenuItem("订单信息");
goodsItem2 = new JMenuItem("库存商品信息");
inforItem2 = new JMenuItem("订单详细信息");
consumerItem3 = new JMenuItem("顾客信息");
bookItem3 = new JMenuItem("订单信息");
goodsItem3 = new JMenuItem("库存商品信息");
inforItem3 = new JMenuItem("订单详细信息");
consumerItem4 = new JMenuItem("顾客信息");
bookItem4 = new JMenuItem("订单信息");
goodsItem4 = new JMenuItem("库存商品信息");
inforItem4 = new JMenuItem("订单详细信息");
printItem1 = new JMenuItem("打印发票 ");
printItem2 = new JMenuItem("打印未付款订单");
printItem3 = new JMenuItem("打印未发货订单");
printItem4 = new JMenuItem("打印通信标签");
proItem1 = new JMenuItem("生产厂家信息");
proItem2 = new JMenuItem("生产厂家信息");
proItem3 = new JMenuItem("生产厂家信息");
proItem4 = new JMenuItem("生产厂家信息");
exitItem = new JMenuItem("退出");
searchMenu.add(consumerItem1);
searchMenu.addSeparator();
searchMenu.add(bookItem1);
searchMenu.addSeparator();
searchMenu.add(goodsItem1);
searchMenu.addSeparator();
searchMenu.add(inforItem1);
searchMenu.addSeparator();
searchMenu.add(proItem1);
delMenu.add(consumerItem2);
delMenu.addSeparator();
delMenu.add(bookItem2);
delMenu.addSeparator();
delMenu.add(goodsItem2);
delMenu.addSeparator();
delMenu.add(inforItem2);
delMenu.addSeparator();
delMenu.add(proItem2);
insertMenu.add(consumerItem3);
insertMenu.addSeparator();
insertMenu.add(bookItem3);
insertMenu.addSeparator();
insertMenu.add(goodsItem3);
insertMenu.addSeparator();
insertMenu.add(inforItem3);
insertMenu.addSeparator();
insertMenu.add(proItem3);
modifyMenu.add(consumerItem4);
modifyMenu.addSeparator();
modifyMenu.add(bookItem4);
modifyMenu.addSeparator();
modifyMenu.add(goodsItem4);
modifyMenu.addSeparator();
modifyMenu.add(inforItem4);
modifyMenu.addSeparator();
modifyMenu.add(proItem4);
menu.add(printItem1);
menu.addSeparator();
menu.add(printItem2);
menu.addSeparator();
menu.add(printItem3);
menu.addSeparator();
menu.add(printItem4);
menu.addSeparator();
menu.add(exitItem);
menubar.add(searchMenu);
menubar.add(delMenu);
menubar.add(insertMenu);
menubar.add(modifyMenu);
menubar.add(menu);
setVisible(true);
setJMenuBar(menubar);
validate();
//Panel.add(box);
Panel.setLayout(new FlowLayout());
add(Panel);
consumerItem1.addActionListener(this);
consumerItem2.addActionListener(this);
consumerItem3.addActionListener(this);
consumerItem4.addActionListener(this);
bookItem1.addActionListener(this);
bookItem2.addActionListener(this);
bookItem3.addActionListener(this);
bookItem4.addActionListener(this);
goodsItem1.addActionListener(this);
goodsItem2.addActionListener(this);
goodsItem3.addActionListener(this);
goodsItem4.addActionListener(this);
inforItem1.addActionListener(this);
inforItem2.addActionListener(this);
inforItem3.addActionListener(this);
inforItem4.addActionListener(this);
proItem1.addActionListener(this);
proItem2.addActionListener(this);
proItem3.addActionListener(this);
proItem4.addActionListener(this);
exitItem.addActionListener(this);
printItem1.addActionListener(this);
printItem2.addActionListener(this);
printItem3.addActionListener(this);
printItem4.addActionListener(this);
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
}
public void actionPerformed(ActionEvent e)
{
if(e.getSource() == consumerItem1)
{
new consumerSearchRecord("查询顾客信息").setVisible(true);
}
if(e.getSource() == consumerItem2)
{
new consumerDelRecord("删除顾客信息").setVisible(true);
}
else if(e.getSource() == consumerItem3)
{
new consumerInsertRecord("插入顾客信息").setVisible(true);
}
else if(e.getSource() == consumerItem4)
{
new consumerModifyRecord("修改顾客信息").setVisible(true);
}
else if(e.getSource() == bookItem1)
{
new bookSearchRecord("查询订单信息").setVisible(true);
}
else if(e.getSource() == bookItem2)
{
new bookDelRecord("删除订单信息").setVisible(true);
}
else if(e.getSource() == bookItem3)
{
new bookInsertRecord("插入订单信息").setVisible(true);
}
else if(e.getSource() == bookItem4)
{
new bookModifyRecord("修改订单信息").setVisible(true);
}
else if(e.getSource() == goodsItem1)
{
new goodsSearchRecord("查询库存商品信息").setVisible(true);
}
else if(e.getSource() == goodsItem2)
{
new goodsDelRecord("删除库存商品信息").setVisible(true);
}
else if(e.getSource() == goodsItem3)
{
new goodsInsertRecord("插入库存商品信息").setVisible(true);
}
else if(e.getSource() == goodsItem4)
{
new goodsModifyRecord("修改库存商品信息").setVisible(true);
}
else if(e.getSource() == inforItem1)
{
new inforSearchRecord("查询订单细则").setVisible(true);
}
else if(e.getSource() == inforItem2)
{
new inforDelRecord("删除订单细则").setVisible(true);
}
else if(e.getSource()== inforItem3)
{
new inforInsertRecord("插入订单细则").setVisible(true);
}
else if(e.getSource()== inforItem4)
{
new inforModifyRecord("修改订单细则").setVisible(true);
}
else if(e.getSource() == proItem1)
{
new productSearchRecord("查询生产厂家信息").setVisible(true);
}
else if(e.getSource() == proItem2)
{
new productDelRecord("删除生产厂家信息").setVisible(true);
}
else if(e.getSource() == proItem3)
{
new productInsertRecord("插入生产厂家信息").setVisible(true);
}
else if(e.getSource() == proItem4)
{
new productModifyRecord("修改生产厂家信息").setVisible(true);
}
else if(e.getSource() == printItem1)
{
new PrintRecord("打印发票").setVisible(true);
}
else if(e.getSource() == printItem2)
{
new printinforRecord();
}
else if(e.getSource() == printItem3)
{
new printinfor1Record();
}
else if(e.getSource() == printItem4)
{
new printlableRecord("打印通信标签").setVisible(true);
}
else if(e.getSource() == exitItem)
{
int n = JOptionPane.showConfirmDialog(this, "确定退出?","确认对话框",JOptionPane.YES_NO_OPTION);
if(n == JOptionPane.YES_OPTION)
{
System.exit(0);
}
}
}
}
- 1
- 2
前往页