?? findshow.java
字號:
package control.view.prodout;import java.awt.*;import javax.swing.*;import java.awt.event.*;import beans.ProdOut;public class FindShow extends JDialog implements ActionListener{ private static String msg=""; private JButton jb_find=new JButton("查找"); private JButton jb_exit=new JButton("取消"); private JLabel la_pINum=new JLabel("總數量:"); private JLabel la_pITotalMoney=new JLabel("總金額:"); private JLabel la_pIByer=new JLabel("經辦人:"); private JLabel la_pIStorager=new JLabel("庫管員:"); private JLabel la_pITime=new JLabel("出庫日期:"); private JTextField tf_pINum=new JTextField(); private JTextField tf_pITotalMoney=new JTextField(); private JTextField tf_pIByer=new JTextField(); private JTextField tf_pIStorager=new JTextField(); private JTextField tf_pITime=new JTextField(); public static ProdOut pro; public void actionPerformed(ActionEvent e){ if(e.getSource() instanceof JButton){ JButton b=(JButton)e.getSource(); if(b == jb_find){ try{ if(getProdOut() == null){ throw new Exception(msg); }else{ this.pro=this.getProdOut(); this.dispose(); ((JFrame)this.getParent()).dispose(); new FindProdOut("查詢出庫單結果"); } }catch(Exception ep){ System.out.println(ep.getMessage()); JOptionPane.showMessageDialog(this, msg); } }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_pINum.setBounds(100,20,110,30); la_pITotalMoney.setBounds(100,70,110,30); la_pIByer.setBounds(100,120,110,30); la_pIStorager.setBounds(100,170,110,30); la_pITime.setBounds(80,220,150,30); tf_pINum.setBounds(210,20,150,30); tf_pITotalMoney.setBounds(210,70,150,30); tf_pIByer.setBounds(210,120,150,30); tf_pIStorager.setBounds(210,170,100,30); tf_pITime.setBounds(210,220,100,30); jb_find.setBounds(100,270,100,35); jb_exit.setBounds(220,270,100,35); this.add(la_pINum); this.add(tf_pINum); this.add(la_pITotalMoney); this.add(tf_pITotalMoney); this.add(la_pIByer); this.add(tf_pIByer); this.add(la_pIStorager); this.add(tf_pIStorager); this.add(la_pITime); this.add(tf_pITime); jb_find.addActionListener(this); jb_exit.addActionListener(this); this.add(jb_find); this.add(jb_exit); } private ProdOut getProdOut() throws Exception{ int pINum=0; double pITotalMoney=0.0; String pIByer="",pIStorager=""; String pITime=""; if(!tf_pINum.getText().equals("")){ try{ pINum=Integer.parseInt(tf_pINum.getText()); }catch(Exception e){ msg="請確認輸入的數量和金額是數值"; return null; } }else{ pINum=0; } if(!tf_pITotalMoney.getText().equals("")){ try{ pITotalMoney=Double.parseDouble(tf_pITotalMoney.getText()); }catch(Exception e){ msg="請確認輸入的數量和金額是數值"; return null; } }else{ pITotalMoney=0; } if(!tf_pIByer.getText().equals("")){ pIByer=tf_pIByer.getText(); }else{ pIByer=""; } if(!tf_pIStorager.getText().equals("")){ pIStorager=tf_pIStorager.getText(); }else{ pIStorager=""; } if(!tf_pITime.getText().equals("")){ try{ pITime=tf_pITime.getText(); }catch(Exception e){ System.out.println(e.getMessage()); return null; } }else{ pITime=""; } return new ProdOut( "", pINum, pITotalMoney, pIByer, pIStorager, pITime, "" ); } 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 + -