• Post Reply Bookmark Topic Watch Topic
  • New Topic

getting a table to refreshing upon clicking button  RSS feed

 
Jason McKinley
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello all,

As the subject says, I am trying to get the table to refresh when I click the save button, which also adding more data. I have tried using:



In the action listener but it doesn't seem to work. Anyway what I am trying to do is make it where after it save the data, it refreshes the table to show that the new data has been added.

The code:
 
Rob Spoor
Sheriff
Posts: 21095
85
Chrome Eclipse IDE Java Windows
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You'll need to re-read the file again. The table model doesn't know it got its data from the file; it uses its own in-memory storage instead. By triggering that event it won't automatically refresh its data from the file.
 
Jason McKinley
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Rob Spoor wrote:You'll need to re-read the file again. The table model doesn't know it got its data from the file; it uses its own in-memory storage instead. By triggering that event it won't automatically refresh its data from the file.


What would be the best code to do this with? You don't have to write out the code for me just point me in the direction I should be looking. I'm not looking for someone to write the code, I'd never learn that way :P
 
Ranganathan Kaliyur Mannar
Bartender
Posts: 1103
10
Java Netbeans IDE Ubuntu
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You already have the code written for reading the file. You just have to refactor some of the code, like:
1) Change the method InsertData - this should clear the existing data in the model and then add the rows.
2) You can then call this method whenever you save the file.
 
Jason McKinley
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Great, that's what I thought I would have to do. I just wanted to make sure before I did it, I am still so new to java and am not confident in myself yet. After your post I started playing around to that line of code and got it working just the way I wanted it to. Thanks for the help.
 
Ranganathan Kaliyur Mannar
Bartender
Posts: 1103
10
Java Netbeans IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You're welcome.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!