⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 findshow.java

📁 利用java swing实现简单的单机版仓库管理
💻 JAVA
字号:
package control.view.product;import java.awt.*;import javax.swing.*;import java.awt.event.*;import beans.Product;public class FindShow extends JDialog implements ActionListener{    private JButton jb_find=new JButton("查找");    private JButton jb_exit=new JButton("取消");    private JLabel la_pName=new JLabel("产品名称:");    private JLabel la_pType=new JLabel("产品类型:");    private JLabel la_pClassID=new JLabel("产品规格类型:");    private JLabel la_pUnit=new JLabel("产品单位:");    private JLabel la_pPrice=new JLabel("产品单价(必须数值):");    private JTextField tf_pName=new JTextField();    private JTextField tf_pType=new JTextField();    private JTextField tf_pClassID=new JTextField();    private JTextField tf_pUnit=new JTextField();    private JTextField tf_pPrice=new JTextField();        public static Product pro;    public void actionPerformed(ActionEvent e){                if(e.getSource() instanceof JButton){            JButton b=(JButton)e.getSource();                        if(b == jb_find){                try{                    this.pro=this.getProduct();                    this.dispose();                    ((JFrame)this.getParent()).dispose();                    new FindProducts("查询产品结果");                }catch(Exception ep){                    System.out.println(ep.getMessage());                }            }else if(b == jb_exit){                if( (JOptionPane.showConfirmDialog(this, new String("是否真的退出?")))==                        JOptionPane.YES_OPTION) {                    this.dispose();                }            }        }    }        public FindShow(JFrame fra,String title,boolean model){        super(fra,title,model);        setMid(500, 400, this);        this.setResizable(false);        addComponent();        this.show(true);    }    public void addComponent(){        this.setLayout(null);                la_pName.setBounds(100,20,110,30);        la_pType.setBounds(100,70,110,30);        la_pClassID.setBounds(100,120,110,30);        la_pUnit.setBounds(100,170,110,30);        la_pPrice.setBounds(80,220,150,30);                tf_pName.setBounds(210,20,150,30);        tf_pType.setBounds(210,70,150,30);        tf_pClassID.setBounds(210,120,150,30);        tf_pUnit.setBounds(210,170,100,30);        tf_pPrice.setBounds(210,220,100,30);                jb_find.setBounds(100,270,100,35);        jb_exit.setBounds(220,270,100,35);                this.add(la_pName);        this.add(tf_pName);        this.add(la_pType);        this.add(tf_pType);        this.add(la_pClassID);                this.add(tf_pClassID);         this.add(la_pUnit);        this.add(tf_pUnit);        this.add(la_pPrice);        this.add(tf_pPrice);                jb_find.addActionListener(this);        jb_exit.addActionListener(this);        this.add(jb_find);        this.add(jb_exit);    }    private Product getProduct() throws Exception{        String pName="",pType="",pClassID="",pUnit="";        Double pPrice=0.0;        if(!tf_pPrice.getText().equals("")){            pPrice=Double.parseDouble(tf_pPrice.getText());        }        if(!tf_pName.getText().equals("")){            pName=tf_pName.getText();        }        if(!tf_pType.getText().equals("")){            pType=tf_pType.getText();        }        if(!tf_pClassID.getText().equals("")){            pClassID=tf_pClassID.getText();        }        if(!tf_pUnit.getText().equals("")){            pUnit=tf_pName.getText();        }        return new Product(            pName,            pType,            pClassID,            pUnit,            pPrice          );    }        public void setMid(int width,int height,java.awt.Window fra){        Dimension ds=Toolkit.getDefaultToolkit().getScreenSize();        int x=new Double( (ds.getWidth()-width)/2 ).intValue();        int y=new Double( (ds.getHeight()-height)/2 ).intValue();        fra.setBounds(x,y,width,height);    }}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -