Results 1 to 4 of 4
- 08-05-2009, 12:16 PM #1
Member
- Join Date
- Aug 2009
- Posts
- 21
- Rep Power
- 0
Dynamic Refresh in JTable every 5 Minutes
I have developed JTable and it displays the data in table.
But i want the Jtable to update the content every five minutes
and the newly added Records(data) should be always at first and
old records Should be below (Similar to Stack Opeartions)
Record is read from the txt file.the txt file updated every three minutes.
So kindly Give an idea to solve these problems:) javadeveloper
- 08-05-2009, 01:11 PM #2
Hmm. TimerTask to schedule the reading. Read the file, reverse the lines (I reckon new lines are at the bottom of the file), populate a new TableModel and set that to your table.
-
Or perhaps a javax.swing.Timer, but whichever you use, you should take care to do the file reading in a background thread and the JTable/table model manipulations on the EDT (sorry if you already know this). A Swing Timer will do everything on the EDT, so I would use it in conjunction with a SwingWorker object. Also, if you extend an AbstractTableModel, the data itself can be held in a stack.
Last edited by Fubarable; 08-05-2009 at 03:28 PM.
- 08-07-2009, 05:16 AM #4
Given the long periods of time between updates and the (potential) need to do the data updates off the EDT, I would just use a thread. Have it do sleep(100) and check for a "stop" flag between updates. Once the update information is collected, post the update using EventQueue.invokeLater(). This is a very simple approach and it is extensible.
As far as your table, implement your own TableModel class. Don't do any of the array of array nonsense. Create a simple Row class, and put the rows in a list. Put the new row on top of the list. Clean and simple.
Similar Threads
-
Inside a Timer thread loop,how to refresh a JTable in swing
By neha_negi in forum Threads and SynchronizationReplies: 3Last Post: 09-04-2009, 01:45 AM -
how to refresh data of the JTable
By paty in forum JDBCReplies: 3Last Post: 08-17-2008, 12:01 PM -
Dynamic JTable
By eftenpuften in forum AWT / SwingReplies: 0Last Post: 07-24-2008, 03:41 PM -
Jtable duplicates through Hashtable (JTable condition problem) my assignment plz help
By salmanpirzada1 in forum Advanced JavaReplies: 2Last Post: 05-15-2008, 10:15 AM -
How to beep every 5 minutes in Java
By Java Tip in forum java.langReplies: 0Last Post: 04-16-2008, 10:40 PM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks