aspose file tools*
The moose likes Swing / AWT / SWT and the fly likes Refreshing a GUI Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "Refreshing a GUI" Watch "Refreshing a GUI" New topic
Author

Refreshing a GUI

Fred Victa
Ranch Hand

Joined: May 01, 2008
Posts: 96
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

Joined: Jan 28, 2003
Posts: 4181
    
  21

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.


Steve
Fred Victa
Ranch Hand

Joined: May 01, 2008
Posts: 96
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

Joined: Jun 13, 2009
Posts: 2216
    
    7
The DefaultTableModel has methods like:



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

 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Refreshing a GUI