This week's book giveaways are in the Java EE and JavaScript forums.
We're giving away four copies each of The Java EE 7 Tutorial Volume 1 or Volume 2(winners choice) and jQuery UI in Action and have the authors on-line!
See this thread and this one for details.
The moose likes Swing / AWT / SWT and the fly likes JTable is not getting updated Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "JTable is not getting updated" Watch "JTable is not getting updated" New topic
Author

JTable is not getting updated

Rohit Kedia
Ranch Hand

Joined: Apr 24, 2010
Posts: 79
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

Joined: Feb 23, 2007
Posts: 1561
Define "updating" the JTable? Are you updating the JTable's model? Because that's mainly what you need to do.
Rohit Kedia
Ranch Hand

Joined: Apr 24, 2010
Posts: 79
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

Joined: Oct 27, 2005
Posts: 19679
    
  18

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.


SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6
How To Ask Questions How To Answer Questions
Rohit Kedia
Ranch Hand

Joined: Apr 24, 2010
Posts: 79
It worked as you guided ... Thanks a Billion....
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: JTable is not getting updated