package Frame; import java.awt.BorderLayout; import java.awt.Container; import java.awt.Dimension; import java.awt.Toolkit; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.awt.event.WindowEvent; import java.awt.event.WindowListener; import java.util.Iterator; import java.util.Vector; import javax.swing.Box; import javax.swing.ComboBoxModel; import javax.swing.DefaultComboBoxModel; import javax.swing.ImageIcon; import javax.swing.JComboBox; import javax.swing.JDialog; import javax.swing.JPanel; import javax.swing.JScrollPane; import javax.swing.JTable; import javax.swing.JTextField; import javax.swing.table.DefaultTableModel; import BaoWen.Dell_55AA07; import ColorAndFont.NothJPanel; import ColorAndFont.UIColor; import ColorAndFont.buttonTitle; import DataBase.DatabaseManagement; import Method.GetNowTime; import PbuliClass.JButtonModel; import PbuliClass.JlableModel; import PbuliClass.ShowMessage; import PbuliClass.Systems; import PbuliClass.WarningMessage; import PbuliClass.greateTables; import PbuliClass.jinternalFrame; import fence.Fences; import shiping.Dell_shiping; import shiping.tb_shipin; @SuppressWarnings("serial") public class ShipingManage extends jinternalFrame{ JTextField JF_serch=null;//ËÑË÷Îı¾¿ò JButtonModel Jbt_search=null;//ËÑË÷°´Å¥ JButtonModel Jbt_shuaxin=null;//ˢа´Å¥ JButtonModel Jbt_add=null;//ÐÂÔö°´Å¥ JButtonModel Jbt_alter=null;//Ð޸İ´Å¥ JButtonModel Jbt_delete=null;//ɾ³ý°´Å¥ JButtonModel Jbt_deleteAll=null;//È«²¿É¾³ý°´Å¥ NothJPanel northPanel=null;//±±²¿Ãæ°å JPanel centerPanel=null;//Öв¿Ãæ°å JScrollPane gd=null;//¹ö¶¯Ãæ°å JTable table=null;//ÉêÃ÷±í¸ñ DefaultTableModel tableModel=null;//ÉùÃ÷±í¸ñÄ£ÐÍ AddAchorDialog AddAchorDialog1=null; public ShipingManage() {//¹¹Ôì·½·¨ this.setTitle("ÊÓÆµ¹ÜÀí"); this.setFrameIcon(new ImageIcon("image/icon/vediao.png"));//ÉèÖô°Ìåͼ±ê Container rq=getContentPane();//»ñÈ¡ÈÝÆ÷ rq.setLayout(new BorderLayout()); rq.setBackground(UIColor.getNorth_color()); rq.add(getNorthPanel(),BorderLayout.NORTH); rq.add(getGd(),BorderLayout.CENTER); } /**»ñÈ¡±±²¿Ãæ°åµÄ·½·¨*/ public NothJPanel getNorthPanel() { if(northPanel==null) { northPanel=new NothJPanel(); Box topicBox = Box.createHorizontalBox();// ´´½¨Ò»¸öˮƽÏäÈÝÆ÷ topicBox.add(getJF_serch());//Ìí¼ÓËÑË÷Îı¾¿ò topicBox.add(Box.createHorizontalStrut(3));// Ìí¼ÓÒ»¸ö3ÏñËØ¿íµÄˮƽ֧Öù topicBox.add(getJbt_search());//Ìí¼ÓËÑË÷°´Å¥ topicBox.add(Box.createHorizontalStrut(5));// Ìí¼ÓÒ»¸ö5ÏñËØ¿íµÄˮƽ֧Öù topicBox.add(getJbt_shuaxin());//Ìí¼Óˢа´Å¥ topicBox.add(Box.createHorizontalStrut(5));// Ìí¼ÓÒ»¸ö5ÏñËØ¿íµÄˮƽ֧Öù topicBox.add(getJbt_add());//Ìí¼ÓÐÂÔö°´Å¥ topicBox.add(Box.createHorizontalStrut(5));// Ìí¼ÓÒ»¸ö5ÏñËØ¿íµÄˮƽ֧Öù topicBox.add(getJbt_alter());//Ìí¼ÓÐ޸İ´Å¥ topicBox.add(Box.createHorizontalStrut(5));// Ìí¼ÓÒ»¸ö5ÏñËØ¿íµÄˮƽ֧Öù topicBox.add(getJbt_delete());//Ìí¼Óɾ³ý°´Å¥ topicBox.add(Box.createHorizontalStrut(5));// Ìí¼ÓÒ»¸ö5ÏñËØ¿íµÄˮƽ֧Öù topicBox.add(getJbt_deleteAll());//Ìí¼Óɾ³ýÈ«²¿°´Å¥ northPanel.add(topicBox ); } return northPanel; } /**»ñÈ¡Öв¿Ãæ°åµÄ·½·¨*/ public JPanel getCenterPanel() { if(centerPanel==null) { centerPanel=new JPanel(); centerPanel.add(getGd());//Ìí¼Ó¹ö¶¯Ãæ°å centerPanel.setBackground(UIColor.getNorth_color()); } return centerPanel; } /**»ñÈ¡¹ö¶¯Ãæ°åµÄ·½·¨*/ public JScrollPane getGd() { if(gd==null){ gd=new JScrollPane(); gd.getViewport().setBackground(UIColor.getNorth_color()); gd.setViewportView(getTable()); } return gd; } /**»ñÈ¡»ùÕ¾±í¸ñµÄ·½·¨*/ @SuppressWarnings("rawtypes") public JTable getTable() { if(table==null) { String name1="ÐòºÅ"; String name2="ÇøÓò"; String name3="±àºÅ"; String name4="ͨµÀ"; String name5="x×ø±ê"; String name6="y×ø±ê"; String name7="z×ø±ê"; String name8="ËùÔÚ²ã"; String name9="Ãû³Æ"; String name10="Ìí¼Óʱ¼ä"; if(Systems.sys().getLanguage().equals("English")) { name1="xuhao"; name2="quyu"; name3="bianhao)"; name4="tongdao"; name5="x"; name6="y"; name7="z"; name8="floor"; name9="name"; name10="addtime"; } //Ìí¼Ó±í¸ñÁÐÏòÁ¿ String[] columnNames= {name1,name2,name3,name4,name5,name6,name7, name8,name9,name10};//±í¸ñÁÐÃû Vector columnName=new Vector<>(); for(int i=0;i shiping_vector ) { Iterator iterator = shiping_vector.iterator();//´´½¨µü´úÆ÷ while (iterator.hasNext()) {//µü´úÆ÷´æÔÚÔªËØ tb_shipin sp= iterator.next();//½«µü´úÆ÷ÀïÃæµÄÔªËØ¸øµ½list¼¯ºÏ Vector row = new Vector(); row.add(sp.getId()); row.add(sp.getFencename()); row.add(sp.getShebeiid()); row.add(sp.getTongdaoid()); row.add(sp.getPosx()); row.add(sp.getPosy()); row.add(sp.getPosz()); row.add(sp.getFloor()); row.add(sp.getName()); row.add(sp.getAddtime()); tableModel.addRow(row); } } public JTextField getJF_serch() { if( JF_serch==null) { JF_serch=new JTextField(5); } return JF_serch; } public JButtonModel getJbt_search() { if( Jbt_search==null) { Jbt_search=new JButtonModel("ËÑË÷"); Jbt_search.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { } }); } return Jbt_search; } public JButtonModel getJbt_shuaxin() { if( Jbt_shuaxin==null) { Jbt_shuaxin=new JButtonModel("Ë¢ÐÂ"); Jbt_shuaxin.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { updateTable(); } }); } return Jbt_shuaxin; } public JButtonModel getJbt_add() { if( Jbt_add==null) { Jbt_add=new JButtonModel("ÐÂÔö"); Jbt_add.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { if(AddAchorDialog1==null) { AddAchorDialog1=new AddAchorDialog("ÐÂÔöÊÓÆµ"); } } }); } return Jbt_add; } public JButtonModel getJbt_alter() { if( Jbt_alter==null) { Jbt_alter=new JButtonModel("ÐÞ¸Ä"); Jbt_alter.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { int row=table.getSelectedRow(); if(row!=-1) {//Èç¹ûÑ¡ÖеÄÐв»Îª¿Õ new alertDiolog("ÐÞ¸ÄÊÓÆµ¶Ô»°¿ò"); } else { ShowMessage.zidingyi("ÇëÏÈÑ¡ÖÐÐèÒªÐ޸ĵÄÐÐ!"); return; } } }); } return Jbt_alter; } public JButtonModel getJbt_delete() { if( Jbt_delete==null) { Jbt_delete=new JButtonModel("ɾ³ý"); Jbt_delete.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { //±»Ñ¡ÖÐÐеÄË÷Òý¼¯ºÏ int[] selectedRows=table.getSelectedRows(); if(selectedRows.length !=0) { for(int i=0;i=0;j--){//ÕâÊǹؼü´úÂë tableModel.removeRow(selectedRows[j]);//ɾ³ýÈÎÒⱻѡÖÐÐÐ } table.setModel(tableModel);//¸üбí¸ñÄ£ÐÍ //ɾ³ý³É¹¦ÌáʾÐÅÏ¢ ShowMessage.delteSuccess(selectedRows.length); } else { ShowMessage.chooseRow(buttonTitle.getDelete()); } } }); } return Jbt_delete; } public JButtonModel getJbt_deleteAll() { if( Jbt_deleteAll==null) { Jbt_deleteAll=new JButtonModel("È«²¿É¾³ý"); Jbt_deleteAll.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { //Ñ¡Ôñ¶Ô»°¿òÈçyes·µ»Ø0£¬NO·µ»Ø1£¬È¡Ïû·µ»Ø2 WarningMessage warning=new WarningMessage(); warning.setMessage("Ñ¡Ôñɾ³ýÈ«²¿½«É¾³ýËùÓеıêÇ©¼Ç¼£¡"); int warn=warning.getwarMss(getCenterPanel()); int tagnum=table.getRowCount();//±í¸ñ×ÜÐÐÊý if(tagnum!=0 && warn==0) { Dell_shiping.deleteall(); ShowMessage.zidingyi("ɾ³ýËùÓÐÊÓÆµÊý¾ÝÍê³É..."); updateTable() ; } } }); } return Jbt_deleteAll; } /**ÐÂÔöÊÓÆµ¶Ô»°¿ò*/ class AddAchorDialog extends JDialog implements WindowListener{ JlableModel Jl_name=new JlableModel("ÊÓÆµÃû³Æ:"); JlableModel Jl_quyue=new JlableModel("ÊÓÆµÇøÓò:"); JlableModel Jl_bianhao=new JlableModel("ÊÓÆµ±àºÅ:"); JlableModel Jl_tongdao=new JlableModel("ÊÓÆµÍ¨µÀ:"); JlableModel Jl_posx=new JlableModel("λÖÃX/cm:"); JlableModel Jl_posy=new JlableModel("λÖÃY/cm:"); JlableModel Jl_posz=new JlableModel("λÖÃZ/cm:"); JlableModel Jl_floor=new JlableModel("ËùÔÚ²ã:"); JButtonModel sure=null;//È·¶¨°´Å¥ JButtonModel quxiao=null;//È¡Ïû°´Å¥ JTextField Jt_name=null; JTextField Jt_bianhao=null; JTextField Jt_tongdao=null; JTextField Jt_posx=null; JTextField Jt_posy=null; JTextField Jt_posz=null; JTextField Jt_floor=null; JComboBox Jc_quyu=null;//ËùÓÐÊÓÆµÇøÓò¼¯ºÏ JPanel mb=null;//ÉêÃ÷Ò»¸öÃæ°å /**»ñÈ¡¶Ô»°¿ò·½·¨*/ public AddAchorDialog(String title) { super(); //this.setModal(true);//´°Ìå×èÈû this.setAlwaysOnTop(true);//×ÜÊÇÖö¥ this.setTitle(title); Toolkit toolkit = getToolkit();// »ñµÃ´°Ì幤¾ß°ü Dimension screenSize = toolkit.getScreenSize();// »ñÈ¡ÆÁÄ»´óС int width = (int) (screenSize.width);// ¼ÆËã´°Ìåпí¶È int height = (int) (screenSize.height);// ¼ÆËã´°Ìåпí¶È int w=370; int h=460; int x0=(width-w)/2;//´°Ìåx0×ø±ê int y0=(height-h)/2;//´°Ìåy0×ø±ê Container rq=getContentPane(); rq.add(getMb()); this.setBounds(x0, y0,w ,h); this.setVisible(true); this.addWindowListener((WindowListener) this); this.setIconImage(new ImageIcon("image/icon/vediao.png").getImage()); Dell_55AA07.setTanchu(true); } /**»ñÈ¡Ãæ°å*/ public JPanel getMb() { if(mb==null){ mb=new JPanel(); mb.setLayout(null); mb.add(Jl_name); mb.add(Jl_quyue); mb.add(Jl_bianhao); mb.add(Jl_tongdao); mb.add(Jl_posx); mb.add(Jl_posy); mb.add(Jl_posz); mb.add(Jl_floor); mb.add(getJt_name()); mb.add(getJc_quyu()); mb.add(getJt_bianhao()); mb.add(getJt_tongdao()); mb.add(getJt_posx()); mb.add(getJt_posy()); mb.add(getJt_posz()); mb.add(getJt_floor()); mb.add(getSure()); mb.add(getQuxiao()); int x=40; int y=10; int width=80; int h=25; int j=20; Jl_name.setBounds(x, y, width, h); Jt_name.setBounds(x+width, y, 2*width, h); Jl_quyue.setBounds(x, y+1*(j+h), width, h); Jc_quyu.setBounds(x+width, y+1*(j+h), 2*width, h); Jl_bianhao.setBounds(x, y+2*(j+h), width, h); Jt_bianhao.setBounds(x+width, y+2*(j+h), 2*width, h); Jl_tongdao.setBounds(x, y+3*(j+h), width, h); Jt_tongdao.setBounds(x+width, y+3*(j+h), 2*width, h); Jl_posx.setBounds(x, y+4*(j+h), width, h); Jt_posx.setBounds(x+width, y+4*(j+h), 2*width, h); Jl_posy.setBounds(x, y+5*(j+h), width, h); Jt_posy.setBounds(x+width, y+5*(j+h), 2*width, h); Jl_posz.setBounds(x, y+6*(j+h), width, h); Jt_posz.setBounds(x+width, y+6*(j+h), 2*width, h); Jl_floor.setBounds(x, y+7*(j+h), width, h); Jt_floor.setBounds(x+width, y+7*(j+h), 2*width, h); sure.setBounds(x+20, y+8*(j+h), width, h); quxiao.setBounds(x+width+50, y+8*(j+h), width, h); } return mb; } /**¹Ø±Õ¶Ô»°¿ò·½·¨*/ public void closeDialog() { this.dispose(); AddAchorDialog1=null; } public JButtonModel getSure() { if(sure==null) { sure=new JButtonModel("È·¶¨"); sure.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { String name=Jt_name.getText().trim(); String shebeiid=Jt_bianhao.getText().trim(); String tongdaoid=Jt_tongdao.getText().trim(); String posx=Jt_posx.getText().trim(); String posy=Jt_posy.getText().trim(); String posz=Jt_posz.getText().trim(); String floor=Jt_floor.getText().trim(); String fencename=(String) Jc_quyu.getSelectedItem(); String addtime=GetNowTime.now(); if(shebeiid.length()<1) { ShowMessage.zidingyi("ÊÓÆµidÓдíÎó£¬Çë¼ì²é£¡"); return; } if(posx.length()<1) { posx="0"; } if(posy.length()<1) { posy="0"; } if(posz.length()<1) { posz="0"; } if(floor.length()<1) { floor="0"; } Dell_shiping.add(fencename, shebeiid, tongdaoid, posx, posy, posz, floor,name); //Ïò±í¸ñĩβÌí¼ÓÒ»ÐÐÊý¾Ý Vector addrowData=new Vector(); String num=String.valueOf(table.getRowCount()+1); addrowData.add(num); addrowData.add(fencename); addrowData.add(shebeiid); addrowData.add(tongdaoid); addrowData.add(posx); addrowData.add(posy); addrowData.add(posz); addrowData.add(floor); addrowData.add(name); addrowData.add(addtime); tableModel.addRow(addrowData); ShowMessage.zidingyi("ÊÓÆµÐ´ÈëÊý¾Ý¿â³É¹¦£¡"); } }); } return sure; } public JButtonModel getQuxiao() { if(quxiao==null) { quxiao=new JButtonModel("È¡Ïû"); quxiao.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { closeDialog(); } }); } return quxiao; } public JTextField getJt_name() { if(Jt_name==null) { Jt_name=new JTextField(); } return Jt_name; } public JTextField getJt_bianhao() { if(Jt_bianhao==null) { Jt_bianhao=new JTextField(); } return Jt_bianhao; } public JTextField getJt_tongdao() { if(Jt_tongdao==null) { Jt_tongdao=new JTextField(); } return Jt_tongdao; } public JTextField getJt_posx() { if(Jt_posx==null) { Jt_posx=new JTextField(); } return Jt_posx; } public JTextField getJt_posy() { if(Jt_posy==null) { Jt_posy=new JTextField(); } return Jt_posy; } public JTextField getJt_posz() { if(Jt_posz==null) { Jt_posz=new JTextField(); } return Jt_posz; } public JTextField getJt_floor() { if(Jt_floor==null) { Jt_floor=new JTextField(); } return Jt_floor; } public JComboBox getJc_quyu() { if(Jc_quyu==null) { Jc_quyu=new JComboBox(); String[] a=Fences.getfencesstr("ÊÓÆµÇøÓò"); ComboBoxModel coModel=new DefaultComboBoxModel<>(a);//ÏÂÀ­ÁбíÄ£ÐÍ Jc_quyu.setModel(coModel); } return Jc_quyu; } @Override public void windowOpened(WindowEvent e) { // TODO ×Ô¶¯Éú³ÉµÄ·½·¨´æ¸ù } @Override public void windowClosing(WindowEvent e) { AddAchorDialog1=null; } @Override public void windowClosed(WindowEvent e) { // TODO ×Ô¶¯Éú³ÉµÄ·½·¨´æ¸ù } @Override public void windowIconified(WindowEvent e) { // TODO ×Ô¶¯Éú³ÉµÄ·½·¨´æ¸ù } @Override public void windowDeiconified(WindowEvent e) { // TODO ×Ô¶¯Éú³ÉµÄ·½·¨´æ¸ù } @Override public void windowActivated(WindowEvent e) { // TODO ×Ô¶¯Éú³ÉµÄ·½·¨´æ¸ù } @Override public void windowDeactivated(WindowEvent e) { // TODO ×Ô¶¯Éú³ÉµÄ·½·¨´æ¸ù } } /**Ð޸ĻùÕ¾¶Ô»°¿ò*/ class alertDiolog extends AddAchorDialog{ /** * */ private static final long serialVersionUID = 1L; public alertDiolog(String title) { super(title); int row=table.getSelectedRow(); getJt_name().setText((String)table.getValueAt(row,8)); getJt_bianhao().setEnabled(false); getJt_bianhao().setText((String)table.getValueAt(row,2)); getJt_tongdao().setText((String)table.getValueAt(row,3)); getJt_posx().setText((String)table.getValueAt(row,4)); getJt_posy().setText((String)table.getValueAt(row,5)); getJt_posz().setText((String)table.getValueAt(row,6)); getJt_floor().setText((String)table.getValueAt(row,7)); getJc_quyu().setSelectedItem((String)table.getValueAt(row,1)); } public JButtonModel getSure() { if(sure==null) { sure=new JButtonModel("È·¶¨"); sure.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { String name=getJt_name().getText().trim(); String shebeiid=getJt_bianhao().getText().trim(); String tongdaoid=getJt_tongdao().getText().trim(); String posx=getJt_posx().getText().trim(); String posy=getJt_posy().getText().trim(); String posz=getJt_posz().getText().trim(); String floor=getJt_floor().getText().trim(); String fencename=(String) getJc_quyu().getSelectedItem(); if(shebeiid.length()<1) { ShowMessage.zidingyi("ÊÓÆµidÓдíÎó£¬Çë¼ì²é£¡"); return; } if(posx.length()<1) { posx="0"; } if(posy.length()<1) { posy="0"; } if(posz.length()<1) { posz="0"; } if(floor.length()<1) { floor="0"; } Dell_shiping.alert(fencename, shebeiid, tongdaoid, posx, posy, posz, floor,name); updateTable() ; ShowMessage.zidingyi("ÐÞ¸ÄÊý¾Ý¿â³É¹¦£¡"); } }); } return sure; } } /**ˢбí¸ñ·½·¨*/ public void updateTable() { if(tableModel !=null) { tableModel.getDataVector().clear(); getRowData( Dell_shiping.getShiping_vector()); gd.validate(); } } }