• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Refreshing a GUI

 
Fred Victa
Ranch Hand
Posts: 185
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have an application that displays a GUI and this GUI displays a table with several columns and rows. I have a class that extends DefaultTableModel. I wrote the code that displays the GUI. When the database table changes, how would I updated the GUI dynamically? Do you have any sample code that does that?
 
Steve Luke
Bartender
Posts: 4181
22
IntelliJ IDE Java Python
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Does your database have a feature that would allow it to call arbitrary Java Code when it is updated? Is the update happening from your Java code or do you have to respond to changes that occur to the table from outside your application? You have to determine these things in order to work out a strategy which lets you determine when the data has changed. You might have to have some thread periodically polling the data table for differences (using timestamps when you submit rows helps with this), or, if you are in control of when the data gets sent into the DB then maybe you could register a callback which gets informed when you commit the changes.
 
Fred Victa
Ranch Hand
Posts: 185
1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
My Java code adds new records to the database table and it also updates the records. I would like to refresh the GUI after my Java code adds or updates records in the table, but I'm not sure how to do that.
 
Rob Camick
Ranch Hand
Posts: 2613
9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The DefaultTableModel has methods like:



So you can use those methods to update the TableModel at the same time you update your database.

 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic