package frame; import java.awt.BorderLayout; import java.awt.Color; import java.awt.Container; import java.awt.Dimension; import java.awt.Image; import java.awt.Toolkit; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.awt.event.KeyEvent; import java.awt.event.KeyListener; import java.awt.event.WindowEvent; import java.awt.event.WindowListener; import java.util.Vector; import javax.swing.ComboBoxModel; import javax.swing.DefaultComboBoxModel; import javax.swing.ImageIcon; import javax.swing.JComboBox; import javax.swing.JFrame; import javax.swing.JPanel; import javax.swing.JScrollPane; import javax.swing.JTable; import javax.swing.JTextArea; import javax.swing.JTextField; import javax.swing.table.DefaultTableModel; import data_model.Dell_lixian; import data_model.Dell_shebei; import data_model.Dell_system; import data_model.Jilu; import data_model.tb_shebei; import publicclass.GetNowTime; import publicclass.JButtonModel; import publicclass.JButtonModel2; import publicclass.JlableModel; import publicclass.Savelog; import publicclass.ShowMessage; import publicclass.greateTables; public class Index1 extends JFrame implements WindowListener{ /** * */ private static final long serialVersionUID = 1L; JPanel mb;//Ãæ°å static JTextArea are=null; static String chooseip="1"; static String chooseport=""; static boolean openlog=false; static boolean startjx=false;//¿ªÊ¼Êý¾Ý½âÎö int jisuan=0; JScrollPane gd1; JScrollPane gd2; JScrollPane gd3; JScrollPane gd4;//ÿÈÕ¼à²â½á¹û static JTable table=null;//ÉêÃ÷±í¸ñ JTable table2=null;//ÉêÃ÷±í¸ñ JTable table4=null;//ÉêÃ÷±í¸ñ DefaultTableModel tableModel=null;//ÉùÃ÷±í¸ñÄ£ÐÍ DefaultTableModel tableModel2=null;//ÉùÃ÷±í¸ñÄ£ÐÍ DefaultTableModel tableModel4=null;//ÉùÃ÷±í¸ñÄ£ÐÍ Vector> rowData=null; Vector> rowData2=null; Vector> rowData4=null; static boolean showare=false; JButtonModel but_start=null;//Ñ¡ÔñbinÎļþ JButtonModel but_clear=null;//Ñ¡ÔñbinÎļþ JButtonModel but_shuaxin1=null;//ˢбí¸ñ JButtonModel search=null;//ËÑË÷°´Å¥ static JButtonModel2 tcpnum; static JButtonModel2 udpnum; JButtonModel2 jbt_chushi_enhd=null;//³õʼ»¯Æ«ÒÆÁ¿³õʼֵ JButtonModel2 jbt_send=null;//·¢ËÍÉèÖûù×¼Õ¾×ó±ß JButtonModel2 jbt_getbase_jwd=null;//»ñÈ¡»ù×¼Öµ¾­Î³¶È JTextField searchFileld=null;//ËÑË÷Îı¾¿ò JTextField send_Fileld=null;//ËÑË÷Îı¾¿ò JlableModel jl_UDP=new JlableModel("UDP¼àÌý¶Ë¿Ú:"+Dell_system.getPort()); //JlableModel jl_tcp=new JlableModel("TCP¶Ë¿Ú:"+tcpport); static int num=0; JComboBox datatype=null;//Êý¾ÝÀàÐÍ JComboBox baseanchor=null;//Ñ¡Ôñ»ù×¼Õ¾ID static boolean chushi_enhd=false; static boolean start_jiexi=false; static String tagid="0"; JComboBox box=null; static String xieyi_type="1";//ЭÒéÀàÐÍÑ¡Ôñ public Index1() {//¹¹Ôì·½·¨ Toolkit toolkit = getToolkit();// »ñµÃ´°Ì幤¾ß°ü Dimension screenSize = toolkit.getScreenSize();// »ñÈ¡ÆÁÄ»´óС int width =1500;// ¼ÆËã´°Ìåпí¶È int height =700;// ¼ÆËã´°Ìåпí¶È int w=(int) (screenSize.width* 0.15); int h=(int) (screenSize.height * 0.15); this.setBounds(w,h, width, height);//ÉèÖô°Ìå³ß´ç this.setTitle("ÀëÏ߼ǼÈí¼þV1.01"); Container rq=getContentPane();//»ñÈ¡ÈÝÆ÷ rq.setLayout(new BorderLayout()); rq.setBackground(Color.white); rq.add(getMb(),BorderLayout.CENTER); this.setVisible(true);//ʹ´°Ìå¿É¼û this.addWindowListener((WindowListener) this); this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);//ÉèÖô°Ì幨±Õ·½Ê½ Image image=new ImageIcon("./image/icon/jiance.png").getImage(); this.setIconImage(image); Savelog.save_in_txt("Èí¼þ´ò¿ª"); } public JPanel getMb() { if(mb==null) { mb=new JPanel(); mb.setLayout(null); mb.setBackground(Color.white); int x=5; int y=6; int y2=x+40; mb.add(jl_UDP); // mb.add(jl_tcp); mb.add(getGd1()); mb.add(getGd2()); mb.add(getGd3()); mb.add(getBut_start()); mb.add(getBut_clear()); mb.add(getSearchFileld()); mb.add(getSearch()); //mb.add(getTcpnum()); mb.add(getUdpnum()); mb.add(getBut_shuaxin1()); mb.add(getBox()); jl_UDP.setBounds(x+3, y,140,30); //jl_tcp.setBounds(x+140, y,120,30); //getTcpnum().setBounds(x+140+120+10, y,100,30); getUdpnum().setBounds(x+150, y,250,30); int h1=500; getGd1().setBounds(x, y2,500,500); getSearchFileld().setBounds(x+530, y,150,30); getSearch().setBounds(x+530+155, y,80,30); getBut_shuaxin1().setBounds(x+530+155+100, y,80,30); // getJbt_chushi_enhd().setBounds(x+530+155+200, y,150,30); // getBut_jisuan().setBounds(x+530+155+370, y,100,30); // getBut_openlog().setBounds(x+530+155+490, y,120,30); // getBut_more().setBounds(x+530+155+490+140, y,80,30); getGd2().setBounds(x+530, y2,840,300); getGd3().setBounds(x+530, y2+330,840,200); // getGd4().setBounds(x, y2+650,1370,300); // getBaseanchor().setBounds(x+530, y2+540,200,30); // getSend_Fileld().setBounds(x+740, y2+540,350,30); // getJbt_getbase_jwd().setBounds(x+1100,y2+540,180,30); // getJbt_send().setBounds(x+1290,y2+540,80,30); getBut_start().setBounds(x, y2+h1+20,100,40); getBut_clear().setBounds(x+120, y2+h1+20,100,40); getBox().setBounds(x+240, y2+h1+20,120,40); } return mb; } public void setMb(JPanel mb) { this.mb = mb; } public static JTextArea getAre() { if(are==null) { are=new JTextArea(10,10); are.setBackground(Color.WHITE); are.setForeground(Color.blue); } return are; } public JScrollPane getGd2() { if(gd2==null) { gd2=new JScrollPane(getTable()); gd2.setBackground(Color.white); gd2.setForeground(Color.white); } return gd2; } @Override public void windowActivated(WindowEvent e) { // TODO ×Ô¶¯Éú³ÉµÄ·½·¨´æ¸ù } @Override public void windowClosed(WindowEvent e) { // TODO ×Ô¶¯Éú³ÉµÄ·½·¨´æ¸ù } @Override public void windowClosing(WindowEvent e) { Savelog.save_in_txt("Èí¼þ¹Ø±Õ"); System.exit(0); } @Override public void windowDeactivated(WindowEvent e) { // TODO ×Ô¶¯Éú³ÉµÄ·½·¨´æ¸ù } @Override public void windowDeiconified(WindowEvent e) { // TODO ×Ô¶¯Éú³ÉµÄ·½·¨´æ¸ù } @Override public void windowIconified(WindowEvent e) { // TODO ×Ô¶¯Éú³ÉµÄ·½·¨´æ¸ù } @Override public void windowOpened(WindowEvent e) { // TODO ×Ô¶¯Éú³ÉµÄ·½·¨´æ¸ù } /**Ìí¼Ó±í¸ñÐÐÏòÁ¿Êý¾Ý·½·¨*/ //"±àºÅ","Ãû³Æ","µØÖ·","״̬","¿¨ºÅ","¸üÐÂʱ¼ä","Ìí¼Óʱ¼ä" public void getRowData( Vector tagvc ) { int size=tagvc.size(); for(int i=0;i row = new Vector<>(); row.add(tag.getTagid()); row.add(tag.getName()); row.add(tag.getIp()); String zai=tag.getState(); if(zai.equals("1")) { zai="ÔÚÏß"; }else { zai="ÀëÏß"; } row.add(zai); row.add(tag.getIcid()); row.add(tag.getGengxintime()); row.add(tag.getAddtime()); tableModel.addRow(row); } } /**Ìí¼Ó±í¸ñÐÐÏòÁ¿Êý¾Ý·½·¨*/ public void getRowData2( Vector forwards ) { int size=forwards.size(); for(int i=0;i row = new Vector<>(); row.add(a2.getId()); row.add(a2.getTagid()); row.add(a2.getName()); row.add(a2.getAddtime()); row.add(a2.getAlltime()); tableModel2.addRow(row); } } public JScrollPane getGd1() { if(gd1==null) { gd1=new JScrollPane(getAre()); } return gd1; } public JScrollPane getGd3() { if(gd3==null) { gd3=new JScrollPane(getTable2()); } return gd3; } /**»ñÈ¡»ùÕ¾±í¸ñµÄ·½·¨*/ public JTable getTable() { if(table==null) { //Ìí¼Ó±í¸ñÁÐÏòÁ¿ String[] columnNames= {"±àºÅ","Ãû³Æ","µØÖ·","״̬","¿¨ºÅ","¸üÐÂʱ¼ä","Ìí¼Óʱ¼ä"};//±í¸ñÁÐÃû Vector columnName=new Vector<>(); for(int i=0;i columnName=new Vector<>(); for(int i=0;i=1) { int size=Dell_shebei.getshebeivc(serch).size(); ShowMessage.zidingyi("ËÑË÷µ½Êý¾Ý"+size); updateSerch(serch); }else { ShowMessage.zidingyi("ÄãËÑË÷µÄÉ豸"+serch+"²»´æÔÚ..."); } } }); } return search; } /**ËÑË÷·½·¨*/ public void updateSerch(String a) { if(Dell_shebei.getshebeivc(a).size()==0) { ShowMessage.zidingyi("ÄãËÑË÷µÄÉ豸"+a+"²»´æÔÚ..."); return; } int tagnum=table.getRowCount();//±í¸ñ×ÜÐÐÊý if(tagnum >0 ) { for (int i = 0; i < tagnum; i++) {//ɾ³ýËùÓÐÐÐ tableModel.removeRow(0); } //½«ÁбíÖÐËùÓнá¹û¼¯¸øµ½list¼¯ºÏ getRowData(Dell_shebei.getshebeivc(a)); } } public static JButtonModel2 getTcpnum() { if(tcpnum==null) { tcpnum=new JButtonModel2("TCP:0"); } return tcpnum; } public static JButtonModel2 getUdpnum() { if(udpnum==null) { udpnum=new JButtonModel2("UDP:0"); } return udpnum; } public JButtonModel getBut_shuaxin1() { if(but_shuaxin1==null) { but_shuaxin1=new JButtonModel("ˢбí¸ñ"); but_shuaxin1.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { updateTable(); tagid="0"; } }); } return but_shuaxin1; } /**ˢбí¸ñ·½·¨*/ public void updateTable() { if(tableModel !=null) { if(Dell_shebei.getTagvc().size()!=0) { tableModel.getDataVector().clear(); tableModel2.getDataVector().clear(); getRowData(Dell_shebei.getTagvc()); getRowData2(Dell_lixian.getvec()); gd2.validate(); gd3.validate(); } ShowMessage.zidingyi("Ë¢ÐÂÍê±Ï"); } } public static boolean isShoware() { return showare; } public static void setShoware(boolean showare) { Index1.showare = showare; } public static String getTagid() { return tagid; } public JComboBox getBox() { if(box==null) { box=new JComboBox(); String[] neixing= {"ԭʼÊý¾Ý","½âÎöºóÊý¾Ý","HEXÏÔʾ","ASCLLÏÔʾ"}; ComboBoxModel coModel=new DefaultComboBoxModel<>(neixing);//ÏÂÀ­ÁбíÄ£ÐÍ box.setModel(coModel); box.setBackground(Color.white); box.setSelectedIndex(2); box.addActionListener(new ActionListener() { public void actionPerformed(ActionEvent e) { if(box.getSelectedIndex()==0) { xieyi_type="1"; }else if(box.getSelectedIndex()==1) { xieyi_type="2"; }else if(box.getSelectedIndex()==2) { xieyi_type="3"; }else if(box.getSelectedIndex()==3) { xieyi_type="4"; } } }); } return box; } public static String getXieyi_type() { return xieyi_type; } }