Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

JTable is not getting updated

 
Rohit Kedia
Ranch Hand
Posts: 79
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi ,
I am having a peculiar Issue in JTable.
I am using JTabbedPanes : In one Pane I can TextFields where I can Add User IDs and in the next Tab I have a JTable which shows list of users who have access(basically if I add in the Textfield any User ID that is saving in the Database and then I am updating the JTable).

But the problem is that the JTable is not getting updated.
I had checked and found that the data ; On clicking on any JTable cell I found that then only the Table it is showing updated value.

I have a JTable which is under a ScrollPane which is under a JPanel.

Every time a action is performed I am performing the following action to update a JTable.

0. disabled & enabled the JTable.

1. updating & repaint the Panel

2. updating & repaint the JScrollpane

3. updating & repaint the JTable

It is not working please help........


 
pete stein
Bartender
Posts: 1561
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Define "updating" the JTable? Are you updating the JTable's model? Because that's mainly what you need to do.
 
Rohit Kedia
Ranch Hand
Posts: 79
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
pete stein wrote:Define "updating" the JTable? Are you updating the JTable's model? Because that's mainly what you need to do.


Yes sir I am updating the Table Model.
In My Table Model class I have a List as a reference Whenever I am adding or deleting any data , I am fetching the updated Data from Database and passing the updated list to the Table Model.
 
Rob Spoor
Sheriff
Pie
Posts: 20605
60
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Are you firing the appropriate events when you change the model? If you use / extended DefaultTableModel and are using addRow etc to change the model then the answer is yes - DefaultTableModel does all that for you.
 
Rohit Kedia
Ranch Hand
Posts: 79
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It worked as you guided ... Thanks a Billion....
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic