📄 shoemain.java
字号:
import javax.swing.*;
import javax.swing.border.*;
import java.awt.*;
import java.awt.event.*;
import java.sql.*;
public class ShoeMain extends JFrame {
JMenuBar jmenubar;
JMenu jmenuSystem;
JMenu jmenuProductInfo;
JMenu jmenuProductIn;
JMenu jmenuProductOut;
JMenu jmenuProductStore;
JMenu jmenuHelp;
JMenuItem jmenuItemExit;
JMenuItem jmenuItemProductAdd;
JMenuItem jmenuItemProductUpdate;
JMenuItem jmenuItemProductSearch;
JMenuItem jmenuItemFileIn;
JMenuItem jmenuIteminInfo;
JMenuItem jmenuItemFileOut;
JMenuItem jmenuItemOutInfo;
JMenuItem jmenuItemStore;
JMenuItem jmenuItemAbout;
private void makeGUI(){
jmenubar = new JMenuBar();
setJMenuBar(jmenubar);
jmenuSystem = new JMenu("系统");
jmenuItemExit = new JMenuItem("退出");
jmenuSystem.add(jmenuItemExit);
jmenubar.add(jmenuSystem);
jmenuProductInfo = new JMenu("产品信息管理");
jmenuItemProductAdd = new JMenuItem("添加产品信息");
jmenuItemProductUpdate = new JMenuItem("修改产品信息");
jmenuItemProductSearch = new JMenuItem("查询产品信息");
jmenuProductInfo.add(jmenuItemProductAdd);
jmenuProductInfo.add(jmenuItemProductUpdate);
jmenuProductInfo.add(jmenuItemProductSearch);
jmenubar.add(jmenuProductInfo);
jmenuProductIn = new JMenu("入库管理");
jmenuItemFileIn = new JMenuItem("产品入库");
jmenuIteminInfo = new JMenuItem("产品入库查询");
jmenuProductIn.add(jmenuItemFileIn);
jmenuProductIn.add(jmenuIteminInfo);
jmenubar.add(jmenuProductIn);
jmenuProductOut = new JMenu("出库管理");
jmenuItemFileOut = new JMenuItem("产品出库");
jmenuItemOutInfo = new JMenuItem("产品出库查询");
jmenuProductOut.add(jmenuItemFileOut);
jmenuProductOut.add(jmenuItemOutInfo);
jmenubar.add(jmenuProductOut);
jmenuProductStore = new JMenu("库存管理");
jmenuItemStore = new JMenuItem("库存信息管理");
jmenuProductStore.add(jmenuItemStore);
jmenubar.add(jmenuProductStore);
jmenuHelp = new JMenu("帮助");
jmenuItemAbout = new JMenuItem("关于...");
jmenuHelp.add(jmenuItemAbout);
jmenubar.add(jmenuHelp);
JLabel lb = new JLabel(new ImageIcon("bk.jpg"));
this.getContentPane().setLayout(new BorderLayout());
this.getContentPane().add(lb);
}
public void menuAction(){
jmenuItemExit.addActionListener(
new ActionListener(){
public void actionPerformed(ActionEvent e){
System.exit(0);
}
});
jmenuItemProductAdd.addActionListener(
new ActionListener(){
public void actionPerformed(ActionEvent e){
ProductAdd newAdd = new ProductAdd("添加产品信息");
newAdd.setBounds(160,140,400,350);
newAdd.validate();
newAdd.pack();
newAdd.setVisible(true);
}
});
jmenuItemProductUpdate.addActionListener(
new ActionListener(){
public void actionPerformed(ActionEvent e){
ProductUpdate dlg = new ProductUpdate("修改产品信息");
Dimension dlgSize = dlg.getPreferredSize();
Dimension frmSize = getSize();
Point loc = getLocation();
dlg.setLocation( (frmSize.width - dlgSize.width) / 2 + loc.x,
(frmSize.height - dlgSize.height) / 2 + loc.y);
dlg.pack();
dlg.show();
}
});
jmenuItemProductSearch.addActionListener(
new ActionListener(){
public void actionPerformed(ActionEvent e){
ProductQuery dlg = new ProductQuery("产品信息查询");
Dimension dlgSize = dlg.getPreferredSize();
Dimension frmSize = getSize();
Point loc = getLocation();
dlg.setLocation( (frmSize.width - dlgSize.width) / 2 + loc.x,
(frmSize.height - dlgSize.height) / 2 + loc.y);
dlg.pack();
dlg.show();
}
});
jmenuItemFileIn.addActionListener(
new ActionListener(){
public void actionPerformed(ActionEvent e){
FrameProductIn dlg = new FrameProductIn("产品入库");
dlg.validate();
dlg.setVisible(true);
dlg.setBounds(160,130,500,300);
}
});
jmenuIteminInfo.addActionListener(
new ActionListener(){
public void actionPerformed(ActionEvent e){
FrameProductInInformation dlg = new FrameProductInInformation("产品入库信息管理");
dlg.setBounds(160,140,550,300);
dlg.setVisible(true);
dlg.validate();
}
});
jmenuItemFileOut.addActionListener(
new ActionListener(){
public void actionPerformed(ActionEvent e){
FrameProductOut dlg = new FrameProductOut("产品出库");
dlg.validate();
dlg.setVisible(true);
dlg.setBounds(160,140,500,300);
}
});
jmenuItemOutInfo.addActionListener(
new ActionListener(){
public void actionPerformed(ActionEvent e){
FrameProductOutInformation dlg = new FrameProductOutInformation("产品出库信息管理");
dlg.setBounds(160,140,550,300);
dlg.setVisible(true);
dlg.validate();
}
});
jmenuItemStore.addActionListener(
new ActionListener(){
public void actionPerformed(ActionEvent e){
FrameProductStoryInformation dlg = new FrameProductStoryInformation("产品库存信息管理");
dlg.setBounds(160,130,550,260);
dlg.validate();
dlg.setVisible(true);
}
});
jmenuItemAbout.addActionListener(
new ActionListener(){
public void actionPerformed(ActionEvent e){
FrameAbout dlg = new FrameAbout("关于.......");
Dimension dlgSize = dlg.getPreferredSize();
Dimension frmSize = getSize();
Point loc = getLocation();
dlg.setLocation( (frmSize.width - dlgSize.width) / 2 + loc.x,
(frmSize.height - dlgSize.height) / 2 + loc.y);
dlg.pack();
dlg.show();
}
});
}
public ShoeMain(String title){
super(title);
makeGUI();
menuAction();
addWindowListener(new WinLis());
}
class WinLis extends WindowAdapter
{
public void windowClosing(WindowEvent e)
{
System.exit(0);
}
}
public static void main(String[] args) {
ShoeMain shoe = new ShoeMain("鞋类信息管理系统");
shoe.setBounds(40,20,700,540);
shoe.validate();
shoe.setVisible(true);
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -