• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

getting a table to refreshing upon clicking button

 
Greenhorn
Posts: 18
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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:
 
Sheriff
Posts: 22784
131
Eclipse IDE Spring VI Editor Chrome Java Windows
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
Bartender
Posts: 1104
10
Netbeans IDE Java Ubuntu
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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: 1104
10
Netbeans IDE Java Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You're welcome.
 
My honeysuckle is blooming this year! Now to fertilize this tiny ad:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic