package Frame; import java.awt.BorderLayout; import java.awt.Color; import java.awt.Container; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.awt.event.MouseEvent; import java.awt.event.MouseListener; import java.io.IOException; import java.util.Iterator; import java.util.Vector; import javax.swing.ButtonGroup; import javax.swing.ImageIcon; import javax.swing.JRadioButton; import javax.swing.JPanel; import javax.swing.JScrollPane; import javax.swing.JTable; import javax.swing.JTextArea; import javax.swing.JTextField; import javax.swing.ListSelectionModel; import javax.swing.event.InternalFrameEvent; import javax.swing.event.InternalFrameListener; import javax.swing.table.DefaultTableModel; import ColorAndFont.ChooseFont; import ColorAndFont.English; import ColorAndFont.UIColor; import ColorAndFont.buttonTitle; import DataBase.DatabaseManagement; import Method.JComboBoxModel; import PbuliClass.JButtonModel; import PbuliClass.JlableModel; import PbuliClass.ShowMessage; import PbuliClass.Systems; import PbuliClass.greateTables; import PbuliClass.jinternalFrame; import tbDataModel.Wifidata; import tbDataModel_Dell.DellS2; import tbDataModel_Dell.Dell_Wifi; /* ´ËÀàÓÃÓÚÍøÂçÄ£¿éS2Ïà¹ØÉèÖÃ*/ public class WifiMange extends jinternalFrame implements Runnable{ /** * */ private static final long serialVersionUID = 1L; Container rq; JlableModel jl_name=new JlableModel("Óû§Ãû:"); JlableModel jl_pass=new JlableModel("ÃÜ Âë:"); JlableModel jl_shebeiname=new JlableModel("É豸ID:"); JlableModel jl_port=new JlableModel("Ä¿±ê¶Ë¿Ú:"); JlableModel jl_model=new JlableModel("ЭÒéÀàÐÍ:"); JlableModel jl_moshi=new JlableModel("¹¤×÷ģʽ:"); JlableModel jl_ip=new JlableModel("¾²Ì¬IP:"); JlableModel jl_wangguan=new JlableModel("Íø ¹Ø:"); JlableModel jl_ziwang=new JlableModel("×ÓÍøÑÚÂë:"); JlableModel jl_fuwuip=new JlableModel("Ä¿±êIP:"); JlableModel jl_MAC=new JlableModel("MACµØÖ·:"); JlableModel jl_wifiname=new JlableModel("WIFIÃû³Æ:"); JlableModel jl_wifipass=new JlableModel("WIFIÃÜÂë:"); JlableModel jl_jiamileixing=new JlableModel("¼ÓÃÜÀàÐÍ:"); JlableModel jl_jiamisuanfa=new JlableModel("¼ÓÃÜËã·¨:"); JlableModel jl_sousuoport=new JlableModel("ËÑË÷¶Ë¿Ú:"); JlableModel jl_keyword=new JlableModel("¹Ø¼ü×Ö:"); static JTextField jt_name=new JTextField(Dell_Wifi.getMoren().getWebname()); static JTextField jt_pass=new JTextField(Dell_Wifi.getMoren().getWebPass()); static JTextField jt_shebeiname=new JTextField(Dell_Wifi.getMoren().getAnchorid()); static JTextField jt_port=new JTextField(Dell_Wifi.getMoren().getPort()); static JTextField jt_ip=new JTextField(Dell_Wifi.getMoren().getIp()); static JTextField jt_wangguan=new JTextField(Dell_Wifi.getMoren().getWangguan()); static JTextField jt_ziwang=new JTextField(Dell_Wifi.getMoren().getZiwang()); static JTextField jt_fuwuip=new JTextField(Dell_Wifi.getMoren().getFuwuip()); static JTextField jt_MAC=new JTextField(); static JTextField jt_wifiname=new JTextField(Dell_Wifi.getMoren().getWifiname()); static JTextField jt_wifipass=new JTextField(Dell_Wifi.getMoren().getWifipass()); static JTextField jt_sousuoport=new JTextField(Dell_Wifi.getMoren().getSousuoport()); static JTextField jt_keyword=new JTextField(Dell_Wifi.getMoren().getKeyword()); JComboBoxModel jb_xieyi=null;//ЭÒéÀàÐÍ JComboBoxModel jb_moshi=null;//¹¤×÷ģʽ JComboBoxModel jb_jiamileixing=null;//¼ÓÃÜÀàÐÍ JComboBoxModel jb_jiamisuanfa=null;//¼ÓÃÜËã·¨ ButtonGroup btgroup=null;//ÉêÃ÷°´Å¥×é String ip=null; int selectedrow=0; static JTextArea textArea=null; JButtonModel jbt_serch=null;//ËÑË÷°´Å¥ JButtonModel jbt_help=null;//°ïÖú JButtonModel jbt_save=null;//±£´æ JButtonModel jbt_clear=null;//Çå¿Õ JButtonModel jbt_reboot=null;//ÖØÆô JButtonModel jbt_reset=null;//»Ö¸´³ö³§ÉèÖà JButtonModel jbt_alertall=null;//ÐÞ¸ÄÈ«²¿ JButtonModel jbt_moren=null;//ĬÈϲÎÊý JButtonModel jbt_open=null;//ĬÈϲÎÊý JButtonModel jbt_alertid=null;//ÐÞ¸ÄÉ豸ID JButtonModel jbt_alertip=null;//ÐÞ¸ÄÉ豸ip JRadioButton jc_ip=null; JRadioButton jc_wangguan=null; JRadioButton jc_adress=null; JRadioButton jc_wifiname=null; JRadioButton jc_wifipass=null; JPanel jp_mb=null;//Äϲ¿Ãæ°å JScrollPane gd=null;//¹ö¶¯Ãæ°å JScrollPane gd2=null;//¹ö¶¯Ãæ°å JTable table=null;//ÉêÃ÷±í¸ñ static DefaultTableModel tableModel=null;//ÉùÃ÷±í¸ñÄ£ÐÍ int x1=410; int y1=30; int x2=630; int y2=30; Vector> rowData=null; static boolean alertall=false; boolean startsave=false; int i=0; int sleeptime=530; int k=0;//Ö´ÐеÄ˳Ðò int h=0;//È«²¿ÐÞ¸ÄÖ´ÐеÄ˳Ðò boolean alertallok=false; int anchornum=0; String xieyi="UDP"; public WifiMange() { String title="WIFI¹ÜÀí"; if(Systems.sys().getLanguage().equals("English")) { title="Anchor WIFI Management"; } this.setTitle(title); rq=getContentPane();//»ñÈ¡ÈÝÆ÷ rq.setLayout(new BorderLayout()); rq.setBackground(Color.white); rq.add(getJp_mb()); this.setFrameIcon(new ImageIcon("image/icon/anchoricon.png"));//ÉèÖô°Ìåͼ±ê rowData=new Vector<>(); jt_sousuoport.setEnabled(false); jt_MAC.setEnabled(false); jt_port.setEnabled(false); this.setSize(910,630); this.addInternalFrameListener(new InternalFrameListener() { public void internalFrameOpened(InternalFrameEvent e) { } public void internalFrameIconified(InternalFrameEvent e) { } public void internalFrameDeiconified(InternalFrameEvent e) { } public void internalFrameDeactivated(InternalFrameEvent e) { } public void internalFrameClosing(InternalFrameEvent e) { } public void internalFrameClosed(InternalFrameEvent e) { textArea=null; tableModel=null; Dell_Wifi.setDellwifi(false); } public void internalFrameActivated(InternalFrameEvent e) { } }); } public JPanel getJp_mb() { if(jp_mb==null) { jp_mb=new JPanel(); getBtgroup(); jp_mb.setLayout(null); jp_mb.add(getJbt_serch()); jp_mb.add(getJbt_help() ); jp_mb.add(getGd()); jp_mb.add(getJbt_save()); jp_mb.add(getGd2()); jp_mb.add(getJbt_clear()); jp_mb.add(getJbt_reboot() ); jp_mb.add(getJbt_reset() ); jp_mb.add(getJbt_open()); jp_mb.add(getJc_ip()); jp_mb.add(getJc_wangguan()); jp_mb.add(getJc_adress()); jp_mb.add(getJc_wifiname()); jp_mb.add(getJc_wifipass()); jp_mb.add(getJbt_alertall()); jp_mb.add(jt_wifiname); jp_mb.add(jt_wifipass); jp_mb.add(getJb_jiamileixing()); jp_mb.add(getJb_jiamisuanfa()); jp_mb.add(jl_sousuoport); jp_mb.add(jt_sousuoport); jp_mb.add(getJbt_moren()); gd2.setBounds(x1, y2+320, 410,200); gd.setBounds(10, y1,380,520); jp_mb.add(jt_name); jp_mb.add(jl_moshi); jp_mb.add(jt_pass); jp_mb.add(jt_shebeiname); jp_mb.add(jt_port); jp_mb.add(getJb_moshi()); jp_mb.add(getJb_xieyi()); jp_mb.add(jt_ip); jp_mb.add(jt_wangguan); jp_mb.add(jt_ziwang); jp_mb.add(jt_fuwuip); jp_mb.add(jt_MAC); jp_mb.add(jl_name); jp_mb.add(jl_pass); jp_mb.add(jl_shebeiname); jp_mb.add(jl_port); jp_mb.add(jl_model); jp_mb.add(jl_ip); jp_mb.add(jl_wangguan); jp_mb.add(jl_ziwang); jp_mb.add(jl_fuwuip); jp_mb.add(jl_MAC); jp_mb.add(jl_wifiname); jp_mb.add(jl_wifipass); jp_mb.add(jl_jiamileixing); jp_mb.add(jl_jiamisuanfa); jp_mb.add(jl_keyword); jp_mb.add(jt_keyword); jp_mb.add(getJbt_alertid()); jp_mb.add(getJbt_alertip()); //Óû§Ãû jl_name.setBounds(x1, y1,65, 25); jt_name.setBounds(x1+65, y1, 110, 25); //ÃÜÂë jl_pass.setBounds(x1,y1+40, 65, 25); jt_pass.setBounds(x1+65, y1+40, 110, 25); //É豸Ãû³Æ jl_shebeiname.setBounds(x1, y1+80, 80, 25); jt_shebeiname.setBounds(x1+65, y1+80,50, 25); jbt_alertid.setBounds(x1+120, y1+80,60, 25); //·þÎñÆ÷¶Ë¿Ú jl_port.setBounds(x1, y1+120, 80, 25); jt_port.setBounds(x1+80, y1+120,100, 25); //ЭÒéÀàÐÍ jl_model.setBounds(x1, y1+160, 80, 25); jb_xieyi.setBounds(x1+80, y1+160,100, 25); //¹¤×÷ģʽ jl_moshi.setBounds(x1, y1+200, 80, 25); jb_moshi.setBounds(x1+80, y1+200, 100, 25); //wifiÃû³Æ jl_wifiname.setBounds(x1, y1+240, 80, 25); jt_wifiname.setBounds(x1+80, y1+240,100, 25); jc_wifiname.setBounds(x1+185, y1+240,20, 25); //wifiÃÜÂë jl_wifipass.setBounds(x1, y1+280, 80, 25); jt_wifipass.setBounds(x1+80, y1+280, 100, 25); jc_wifipass.setBounds(x1+185, y1+280,20, 25); //ipµØÖ· jl_ip.setBounds(x2, y2,80, 25); jt_ip.setBounds(x2+80, y2,90, 25); jbt_alertip.setBounds(x2+180, y2,60, 25); jc_ip.setBounds(x2+245, y2,20, 25); //Íø¹Ø jl_wangguan.setBounds(x2, y2+40, 80, 25); jt_wangguan.setBounds(x2+80, y2+40,100, 25); jc_wangguan.setBounds(x2+185, y2+40,20, 25); //×ÓÍøÑÚÂë jl_ziwang.setBounds(x2, y2+80, 80, 25); jt_ziwang.setBounds(x2+80, y2+80,100, 25); //·þÎñÆ÷IPµØÖ· jl_fuwuip.setBounds(x2, y2+120, 80, 25); jt_fuwuip.setBounds(x2+80, y2+120,100, 25); jc_adress.setBounds(x2+185, y2+120,20, 25); //MACµØÖ· jl_MAC.setBounds(x2, y2+160, 80, 25); jt_MAC.setBounds(x2+80, y2+160,100, 25); //¼ÓÃÜÀàÐÍ jl_jiamileixing.setBounds(x2, y2+200, 80, 25); jb_jiamileixing.setBounds(x2+80, y2+200,100, 25); //¼ÓÃÜËã·¨ jl_jiamisuanfa.setBounds(x2, y2+240, 80, 25); jb_jiamisuanfa.setBounds(x2+80, y2+240,100, 25); //ËÑË÷¶Ë¿Ú jl_sousuoport.setBounds(x2, y2+280, 80, 25); jt_sousuoport.setBounds(x2+80, y2+280,100, 25); //ËÑË÷¹Ø¼ü×Ö jl_keyword.setBounds(10, y1+530, 60, 25); jt_keyword.setBounds(70, y1+530, 80, 25); jbt_serch.setBounds(155,y1+530, 60, 25); jbt_moren.setBounds(225,y1+530, 80, 25); jbt_open.setBounds(315,y1+530, 80, 25); jbt_save.setBounds(x1, y1+530, 60, 25); jbt_alertall.setBounds(x1+80, y1+530, 90, 25); jbt_reset.setBounds(x1+190, y1+530,60, 25); jbt_reboot.setBounds(x1+270,y1+530,60, 25); jbt_clear.setBounds(x1+350, y1+530,60, 25); //jbt_help.setBounds(x1, y1+530, 60, 25); } return jp_mb; } /**Æô¶¯Ï̵߳ķ½·¨*/ public void startThread() { Thread t=new Thread(this); t.start(); } /**ËÑË÷°´Å¥*/ public JButtonModel getJbt_serch() { if(jbt_serch==null) { jbt_serch=new JButtonModel(buttonTitle.getSerch()); jbt_serch.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { textArea.setText(""); //Çå¿Õ¼¯ºÏÖеÄÐÅÏ¢ Dell_Wifi.getWifi_vector().removeAllElements(); updateTable(); Dell_Wifi.serch(); selectedrow=-1; ip=null; } }); } return jbt_serch; } /**°ïÖú°´Å¥*/ public JButtonModel getJbt_help() { if(jbt_help==null) { jbt_help=new JButtonModel("more"); jbt_help.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { try { Runtime.getRuntime().exec("cmd /c systemFiles\\IP\\anchormage.exe"); } catch (IOException e1) { e1.printStackTrace(); ShowMessage.zidingyi("´ò¿ªÊ§°Ü£¡"); } } }); } return jbt_help; } /**±£´æ²ÎÊý*/ public JButtonModel getJbt_save() { if(jbt_save==null) { jbt_save=new JButtonModel(buttonTitle.getSave()); jbt_save.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { if(ip==null) { ShowMessage.zidingyi("ÇëÑ¡ÖÐÐèÒª±£´æµÄÉ豸ip"); return; } textArea.setText(""); if(jt_MAC.getText().length()<5) { ShowMessage.zidingyi("ÇëÏÈÑ¡ÔñÐèÒªÐ޸ĵÄÉ豸£¡"); return; } if(i==0) { if(jb_xieyi.getSelectedIndex()==0) { xieyi="TCP"; }else { xieyi="UDP"; } startThread(); i=1; } startsave=true; alertallok=false; k=0; } }); } return jbt_save; } /**ˢбí¸ñ·½·¨*/ public void updateTable() { if(tableModel !=null) { tableModel.getDataVector().clear(); getRowData(Dell_Wifi.getWifi_vector()); gd.validate(); } } /**Ìí¼Ó±í¸ñÐÐÏòÁ¿Êý¾Ý·½·¨*/ public void getRowData( Vector wifidata ) { Iterator iterator = wifidata.iterator();//´´½¨µü´úÆ÷ while (iterator.hasNext()) {//µü´úÆ÷´æÔÚÔªËØ Vector row = new Vector<>(); Wifidata s2 = iterator.next();//½«µü´úÆ÷ÀïÃæµÄÔªËØ¸øµ½list¼¯ºÏ row.add(s2.getIp()); row.add(s2.getAnchorid()); row.add(s2.getMacid()); row.add(s2.getVersion()); tableModel.addRow(row); } } public JScrollPane getGd() { if(gd==null) { gd=new JScrollPane(getTable()); gd.getViewport().setBackground(UIColor.getNorth_color()); } return gd; } public JScrollPane getGd2() { if(gd2==null) { gd2=new JScrollPane(get_text_area()); } return gd2; } /**»ñÈ¡»ùÕ¾±í¸ñµÄ·½·¨*/ public JTable getTable() { if(table==null) { //Ìí¼Ó±í¸ñÁÐÏòÁ¿ String[] name1= {"É豸ip","É豸Ãû³Æ","MACµØÖ·","°æ±¾"};//±í¸ñÁÐÃû String[] name2= {"Device ip","device name","MAC address","version"};//±í¸ñÁÐÃû String[] columnNames=English.columnNames(name1, name2); Vector columnName=new Vector<>(); for(int i=0;i