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.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_door;
|
import data_model.Dell_fangzhuang;
|
import data_model.Tb_door;
|
import data_model.Tb_fangzhuang;
|
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;//ÉêÃ÷±í¸ñ
|
static DefaultTableModel tableModel=null;//ÉùÃ÷±í¸ñÄ£ÐÍ
|
DefaultTableModel tableModel2=null;//ÉùÃ÷±í¸ñÄ£ÐÍ
|
DefaultTableModel tableModel4=null;//ÉùÃ÷±í¸ñÄ£ÐÍ
|
Vector<Vector<String>> rowData=null;
|
Vector<Vector<String>> rowData2=null;
|
Vector<Vector<String>> 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¼àÌý¶Ë¿Ú:8235");
|
//JlableModel jl_tcp=new JlableModel("TCP¶Ë¿Ú:"+tcpport);
|
static int num=0;
|
JComboBox<String> datatype=null;//Êý¾ÝÀàÐÍ
|
JComboBox<String> baseanchor=null;//Ñ¡Ôñ»ù×¼Õ¾ID
|
static String datatypeis="È«²¿Êý¾ÝÀàÐÍ";
|
static boolean chushi_enhd=false;
|
static boolean start_jiexi=false;
|
static String tagid="0";
|
|
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.0");
|
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());
|
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);
|
|
|
|
}
|
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<Tb_door> tagvc ) {
|
int size=tagvc.size();//"É豸±àºÅ","IP","¶Ë¿Ú","°æ±¾","±¨ÎÄÌõÊý","¸üÐÂʱ¼ä"
|
for(int i=0;i<size;i++) {
|
Tb_door tag=tagvc.get(i);
|
Vector<String> row = new Vector<>();
|
row.add(tag.getId());
|
row.add(tag.getTagid());
|
row.add(tag.getAnchorid());
|
row.add(tag.getDistance());
|
row.add(tag.getPower());
|
row.add(tag.getAddtime());
|
tableModel.addRow(row);
|
}
|
}
|
/**Ìí¼Ó±í¸ñÐÐÏòÁ¿Êý¾Ý·½·¨*/
|
public void getRowData2( Vector<Tb_fangzhuang> forwards ) {
|
int size=forwards.size();
|
for(int i=0;i<size;i++) {
|
Tb_fangzhuang a2=forwards.get(i);
|
Vector<String> row = new Vector<>();
|
row.add(a2.getId());
|
row.add(a2.getFzAnchor());
|
row.add(a2.getFzDis());
|
row.add(a2.getAddtime());
|
row.add(a2.getDoor());
|
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= {"ÐòºÅ","±êÇ©±àºÅ","»ùÕ¾±àºÅ","¾àÀë/cm","µçÁ¿","Ìí¼Óʱ¼ä"};//±í¸ñÁÐÃû
|
Vector<String> columnName=new Vector<>();
|
for(int i=0;i<columnNames.length;i++){
|
columnName.add(columnNames[i]);
|
}
|
|
greateTables tables=new greateTables();
|
if(tableModel==null) {
|
tableModel=new DefaultTableModel(rowData, columnName){
|
/**
|
*
|
*/
|
private static final long serialVersionUID = 1L;
|
|
// ʵÏÖÈÃÕû¸ö±í¸ñ²»²»ÔÊÐí±»±à¼
|
public boolean isCellEditable(int row,int column){
|
return false;
|
}
|
};
|
table=tables.greateTable(tableModel);
|
table.setBackground(Color.white);
|
getRowData(Dell_door.getvec());
|
|
|
|
}
|
|
}
|
return table;
|
|
}
|
|
public JTable getTable2() {//
|
if(table2==null) {
|
String[] columnNames= {"ÐòºÅ","»ùÕ¾±àºÅ","ÅжϾàÀë","Ìí¼Óʱ¼ä","ÃűàºÅ"};//±í¸ñÁÐÃû
|
//Ìí¼Ó±í¸ñÁÐÏòÁ¿
|
Vector<String> columnName=new Vector<>();
|
for(int i=0;i<columnNames.length;i++){
|
columnName.add(columnNames[i]);
|
}
|
greateTables tables=new greateTables();
|
tableModel2=new DefaultTableModel(rowData2, columnName){
|
/**
|
*
|
*/
|
private static final long serialVersionUID = 1L;
|
|
public boolean isCellEditable(int row,int column){ // ʵÏÖÈÃÕû¸ö±í¸ñ²»²»ÔÊÐí±»±à¼
|
return false;
|
}
|
};
|
|
table2=tables.greateTable(tableModel2);
|
getRowData2(Dell_fangzhuang.getvec());
|
}
|
return table2;
|
|
}
|
|
|
/**@param String message,
|
* @param String ip,
|
* @param int datatypeÊý¾ÝÀàÐÍ*/
|
public static void baowen_show(String message,String ip,String datatype) {
|
if(showare) {
|
if(chooseip.equals("1") || ip.equals(chooseip)) {
|
if(datatypeis.equals("È«²¿Êý¾ÝÀàÐÍ")) {//
|
are.append(GetNowTime.sss()+":"+message+"\n");
|
are.setCaretPosition(are.getText().length());
|
}else if(datatype.equals(datatypeis)) {
|
are.append(message+"\n");
|
are.setCaretPosition(are.getText().length());
|
}
|
}
|
}
|
}
|
|
public static void ara_show(String message) {
|
are.append(GetNowTime.sss()+":"+message+"\n");
|
are.setCaretPosition(are.getText().length());
|
}
|
|
public JButtonModel getBut_start() {
|
if(but_start==null) {
|
but_start=new JButtonModel("²é¿´±¨ÎÄ");
|
but_start.addActionListener(new ActionListener() {
|
public void actionPerformed(ActionEvent e) {
|
if(!showare) {
|
showare=true;
|
but_start.setText("ÔÝÍ£²é¿´");
|
}else {
|
showare=false;
|
but_start.setText("¿ªÊ¼²é¿´");
|
}
|
|
}
|
});
|
|
}
|
return but_start;
|
}
|
|
//
|
public JButtonModel getBut_clear() {
|
if(but_clear==null) {
|
but_clear=new JButtonModel("Çå¿Õ´°¿Ú");
|
but_clear.addActionListener(new ActionListener() {
|
public void actionPerformed(ActionEvent e) {
|
are.setText("");
|
}
|
});
|
|
}
|
return but_clear;
|
}
|
|
public void setBut_start(JButtonModel but_start) {
|
this.but_start = but_start;
|
}
|
|
|
public static int getNum() {
|
return num;
|
}
|
|
public static void setNum(int num) {
|
Index1.num = num;
|
}
|
|
|
/**»ñÈ¡ËÑË÷Îı¾¿òµÄ·½·¨*/
|
public JTextField getSearchFileld() {
|
if(searchFileld==null){
|
searchFileld=new JTextField(10);
|
searchFileld.addKeyListener(new KeyListener() { //¼üÅÌʼþ¼àÌý
|
public void keyTyped(KeyEvent e) {
|
|
}
|
public void keyReleased(KeyEvent e) {
|
int keyCode=e.getKeyCode();
|
if(keyCode==KeyEvent.VK_ENTER) {
|
getSearch().doClick();//ËÑË÷°´Å¥±»µã»÷
|
}
|
}
|
public void keyPressed(KeyEvent e) {
|
|
}
|
});
|
|
}
|
return searchFileld;
|
}
|
|
|
/**»ñÈ¡ËÑË÷°´Å¥µÄ·½·¨*/
|
public JButtonModel getSearch() {
|
if(search==null){
|
search=new JButtonModel("ËÑË÷");
|
search.addActionListener(new ActionListener() {
|
public void actionPerformed(ActionEvent e) {
|
String serch=getSearchFileld().getText().trim();
|
tagid=serch;
|
if(serch.length()>=1) {
|
int size=Dell_door.serch(serch).size();
|
ShowMessage.zidingyi("ËÑË÷µ½Êý¾Ý"+size);
|
updateSerch(serch);
|
}else {
|
ShowMessage.zidingyi("ÄãËÑË÷µÄÉ豸"+serch+"²»´æÔÚ...");
|
}
|
}
|
});
|
|
}
|
return search;
|
}
|
|
/**ËÑË÷·½·¨*/
|
public void updateSerch(String a) {
|
if(Dell_door.serch(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_door.serch(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) {
|
tagid="0";
|
updateTable();
|
}
|
});
|
}
|
return but_shuaxin1;
|
}
|
|
/**ˢбí¸ñ·½·¨*/
|
public void updateTable() {
|
if(tableModel !=null) {
|
if(Dell_door.getvec().size()!=0) {
|
tableModel.getDataVector().clear();
|
getRowData(Dell_door.getvec());
|
gd1.validate();
|
}
|
|
ShowMessage.zidingyi("Ë¢ÐÂÍê±Ï");
|
}
|
}
|
|
public static boolean isShoware() {
|
return showare;
|
}
|
|
public static void setShoware(boolean showare) {
|
Index1.showare = showare;
|
}
|
|
public static String getTagid() {
|
return tagid;
|
}
|
|
|
|
|
|
}
|