How to Update the TableModel From Another Thread
When a Java application needs to store a vast array of data, developers sometimes decide to create a JTable that follows the TableModel specification. By default, JTables can only be updated by the thread that generated them. However, by editing the source code of the applet, you can instruct your program to update a JTable from any other thread.
Instructions
-
-
1
Open the file that contains the source code of your Java applet in Notepad or in your default Java software development kit.
-
2
Type or copy-and-paste the following code snippet in your source code, at the spot where you want to update the table:
thread.this;
JTable = TableModel(tablename);
repaint(x, y, var); -
-
3
Replace "tablename" with the name of the table, "x" and "y" with the coordinates of the cell you want to update and "var" with the name of the variable or the value of the integer you want to assign to that cell.
-
4
Click on "File," and select "Save."
-
1