• Post Reply Bookmark Topic Watch Topic
  • New Topic

JTable not autorefreshing when user clicks on specific row  RSS feed

 
Madhura Keni
Greenhorn
Posts: 3
Eclipse IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hiii...I got this weird problem. my Jtable is refreshing after every 5 seconds .Basicaly i have a function which gets called after every five seconds .Wht this function does is ..It takes values from database stores it in new DefaultTableModel and then through setModel function of JTable ,DefaultModel is added to JTable.Everything works fine but the problem is whenever the user clicks on a particular cell or row ,JTable doesnt get refreshed anymore.Any help would be highly appreciated.I tried fireTableDataChanged and wht not..Dont know how to approach




Currently my database doesnt change automatically so i have inserted a count variable to check if the code is working properly .Have a look at line
obj[i][j] = rsView.getString(j) + ""+count;
 
Rob Camick
Ranch Hand
Posts: 2756
12
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Don't use a TimerTask.

Instead use a Swing Timer.

All changes to the GUI should be done on the Event Dispatch Thread (EDT). Read the section from the Swing tutorial on Concurrency for more information.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!