您好,欢迎访问三七文档
当前位置:首页 > 商业/管理/HR > 市场营销 > java商品管理系统4
//代表各的主页面packagecom.gui;importjava.awt.*;importjavax.swing.*;importjava.awt.event.*;importjava.io.*;importjava.nio.channels.ClosedSelectorException;importjava.sql.*;importjavax.swing.JFileChooser;importjavax.swing.plaf.ScrollBarUI;importjavax.swing.table.DefaultTableColumnModel;importjavax.swing.table.DefaultTableModel;importcom.DateSystem.Good_data;importcom.DateSystem.Goods;importcom.DateSystem.Userdate;importjava.util.List;publicclassMainextendsJFrameimplementsActionListener,AdjustmentListener{/***@paramargs*///主窗体组件MenuBarmenuBar;Menumenu_xitong,menu_guanli,menu_gongju,menu_Help;MenuItemitem_up_password,item_reLanding,item_exit;MenuItemitem_input,item_find,item_delete;MenuItemitem_jisuanqi,item_jishiben,item_beijing;MenuItemitem_LookHelp,item_About;//录入界面要用的组件JPaneljp_btn,jp_main,jp_table,jp_text;JLabellbl_id,lbl_name,lbl_address,lbl_in_price,lbl_out_price,lbl_kucun,lbl_jinhuo,lbl_chuhuo;TextFieldtext_id,text_name,text_address,text_in_price,text_out_price,text_kucun,text_jinhuo,text_chuhuo;JButtonsubmit,reset,delete;JScrollPanejsp;JTabletable;DefaultTableModelmodel;CardLayoutc=newCardLayout();JPanelcard;//查找页面要用的组件JPaneljp1,jp2,jp3;JPaneljp2_main;JButtonfind_id,find_name,find_delete,find_all;JTextFieldtext_find;JScrollPanejsp_find;JTabletable_find;DefaultTableModelmodel_find;//背景更改要用的组件intr=255,g=255,b=255;TextFieldtfr,tfg,tfb;Scrollbarsbr,sbg,sbb;Paneldisplay;JPaneljp3_main;publicMain(){super(主窗口);menuBar=newMenuBar();menu_gongju=newMenu(工具);menu_guanli=newMenu(管理);menu_Help=newMenu(帮助);menu_xitong=newMenu(系统);item_About=newMenuItem(关于);item_beijing=newMenuItem(背景设置);item_LookHelp=newMenuItem(查看帮助);item_up_password=newMenuItem(修改密码);item_reLanding=newMenuItem(重新登录);item_exit=newMenuItem(退出系统);item_jishiben=newMenuItem(记事本);item_jisuanqi=newMenuItem(计算器);item_find=newMenuItem(查找);item_input=newMenuItem(录入);item_delete=newMenuItem(删除);//注册监听item_About.addActionListener(this);item_beijing.addActionListener(this);item_LookHelp.addActionListener(this);item_up_password.addActionListener(this);item_reLanding.addActionListener(this);item_exit.addActionListener(this);item_jishiben.addActionListener(this);item_jisuanqi.addActionListener(this);item_find.addActionListener(this);item_input.addActionListener(this);item_delete.addActionListener(this);menu_xitong.add(item_up_password);menu_xitong.add(item_reLanding);menu_xitong.add(item_exit);menu_guanli.add(item_input);menu_guanli.add(item_find);//menu_guanli.add(item_delete);menu_gongju.add(item_jisuanqi);menu_gongju.add(item_jishiben);menu_gongju.add(item_beijing);menu_Help.add(item_About);menu_Help.add(item_LookHelp);menuBar.add(menu_xitong);menuBar.add(menu_guanli);menuBar.add(menu_gongju);menuBar.add(menu_Help);setMenuBar(menuBar);setResizable(false);initComponents();//调用方法初始化界面Find();change_color();//查找功能的布局以及组建//this.setLayout(newCardLayout());card=newJPanel();card.setLayout(c);card.add(1,jp_main);card.add(2,jp2_main);card.add(3,jp3_main);//this.getContentPane().add(Center,jp_main);this.add(card);this.setSize(1000,500);this.setLocationRelativeTo(null);this.setVisible(true);this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);}//录入界面初始化privatevoidinitComponents(){//构造面板System.out.println(pass);lbl_id=newJLabel(商品编号,JLabel.CENTER);lbl_name=newJLabel(商品名称,JLabel.CENTER);lbl_address=newJLabel(商品产地,JLabel.CENTER);lbl_in_price=newJLabel(进价,JLabel.CENTER);lbl_out_price=newJLabel(售价,JLabel.CENTER);lbl_jinhuo=newJLabel(进货量,JLabel.CENTER);lbl_chuhuo=newJLabel(销售量,JLabel.CENTER);lbl_kucun=newJLabel(库存量,JLabel.CENTER);text_id=newTextField();text_name=newTextField();text_address=newTextField();text_in_price=newTextField();text_out_price=newTextField();text_jinhuo=newTextField();text_chuhuo=newTextField();text_kucun=newTextField();jp_table=newJPanel(newBorderLayout());jp_text=newJPanel(newGridLayout(2,8));jp_text.add(lbl_id);jp_text.add(lbl_name);jp_text.add(lbl_address);jp_text.add(lbl_in_price);jp_text.add(lbl_out_price);jp_text.add(lbl_jinhuo);jp_text.add(lbl_chuhuo);jp_text.add(lbl_kucun);jp_text.add(text_id);jp_text.add(text_name);jp_text.add(text_address);jp_text.add(text_in_price);jp_text.add(text_out_price);jp_text.add(text_jinhuo);jp_text.add(text_chuhuo);jp_text.add(text_kucun);model=newDefaultTableModel(newObject[][]{},newString[]{商品编号,商品名称,商品产地,进价,售价,库存量,进货量,出货量});table=newJTable(model);jsp=newJScrollPane(table);submit=newJButton(录入商品);reset=newJButton(重置信息);delete=newJButton(删除所选商品);submit.addActionListener(this);reset.addActionListener(this);delete.addActionListener(this);jp_btn=newJPanel(newGridLayout(1,3));jp_btn.add(submit);jp_btn.add(delete);jp_btn.add(reset);jp_table.add(Center,jp_text);jp_table.add(South,jp_btn);jp_main=newJPanel(newBorderLayout(10,10));jp_main.add(Center,jsp);jp_main.add(North,jp_table);System.out.println(pass);}//查找面板初始化面板privatevoidFind(){jp1=newJPanel(newGridLayout(1,1));jp2=newJPanel(newGridLayout(1,4));jp3=newJPanel(newBorderLayout());find_id=newJButton(根据商品编号查询);find_name=newJButton(根据商品名称查询);find_all=newJButton(查询所有信息);find_delete
本文标题:java商品管理系统4
链接地址:https://www.777doc.com/doc-6150102 .html