Git

1 import javax.swing.table.*;\r
2 \r
3 public abstract class RefreshAbstractTableModel extends AbstractTableModel\r
4 {\r
5 \r
6         public RefreshAbstractTableModel()\r
7         {\r
8                 Thread refreshThread=new Thread()\r
9                 {\r
10                         public void run()\r
11                         {\r
12                                 //int oldRowCount=0,newRowCount;\r
13                                 try\r
14                                 {\r
15                                         for (;;)\r
16                                         {\r
17                                                 sleep(5000);\r
18                                                 /*\r
19                                                 newRowCount=getRowCount();\r
20                                                 if (oldRowCount<newRowCount)\r
21                                                         fireTableRowsInserted(oldRowCount-1,newRowCount-1);\r
22                                                 if (oldRowCount>newRowCount)\r
23                                                         fireTableRowsDeleted(newRowCount-1,oldRowCount-1);\r
24                                                 fireTableRowsUpdated(0,newRowCount-1);\r
25                                                 oldRowCount=newRowCount;\r
26                                                 */\r
27                                                 fireTableDataChanged();\r
28                                         }\r
29                                 }\r
30                                 catch(Exception e)\r
31                                 {\r
32                                         e.printStackTrace();\r
33                                 }\r
34                         }\r
35                 };\r
36                 refreshThread.start();\r
37         }\r
38         \r
39   public Class getColumnClass(int col)\r
40   {\r
41         return getValueAt(0,col).getClass();\r
42   }\r
43 \r
44 }