File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Swing / AWT / SWT and the fly likes Refreshing JTable contents handling. 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 JTable contents handling." Watch "Refreshing JTable contents handling." New topic

Refreshing JTable contents handling.

Mohammed Ajmal

Joined: Sep 20, 2004
Posts: 29

I have a general question related to refreshing the contents of JTable and handling some application specific requirements.In our application we are planning to refresh the contents of JTable automatically after certain period of time by fetching data from database and update the JTable contents or user has clicked refresh button.

But following scenarios we are planning to handle when refresh is called automatically or user has clicked refresh button.

1) User is working with data of JTable. Like rows of JTable has checkBoxes and user selects them and doing operation like viewing the details of selected rows in new details dialog. So if refreshing is done then the selection will be lost if I update the whole data in JTable.

a)Will it be possible to append the data at the end of JTable rows without disturbing the existing JTable contents.

b) Is it feasible to compare the data of existing rows and newly fetched rows and update only the rows whose values are changed in database or update specifically updated columns. But this comparision for finding changed values will result in performance problems.So are there any other alternatives of doing this, ideas are most welcome.

c) Simple way is to alert the user that data will be updated and everything will be refreshed will be the choice in worst case.

I guess many may have encountered such problems and may have solved it depending on the product requirements.

Ideas and suggestions are most welcome.

I agree. Here's the link:
subject: Refreshing JTable contents handling.
jQuery in Action, 3rd edition