aspose file tools*
The moose likes Developer Certification (SCJD/OCMJD) and the fly likes Questions on JTable Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Soft Skills this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Certification » Developer Certification (SCJD/OCMJD)
Bookmark "Questions on JTable" Watch "Questions on JTable" New topic
Author

Questions on JTable

Walter Tang
Greenhorn

Joined: Aug 13, 2004
Posts: 25
Hello everyone,

When I display the data from database, how can I discard the previous display in JTable. Because, when I do the search the second time, the results are appended to the previous results. That makes user really confused on the table. I hope I describe my problem acurately. Thanks a billion for your help

Walter


SCJP
mike acre
Ranch Hand

Joined: Sep 23, 2003
Posts: 197
It depends on your table model class (I assume you have one).

You can create a new table model for your new data and then re-register it with the view JTable.setModel(myTableModel)

Or better,

you can write or use an existing setData type method that replaces the models collection of records, then fire a AbstractTableModel.fireDataChanged or whatever it's called.


SCJP 1.4, SCJD
Ed Green
Greenhorn

Joined: Jun 15, 2004
Posts: 11
Hi,
You could also try TableModel.setDataVector()?
Richard Jackson
Ranch Hand

Joined: Jun 25, 2003
Posts: 128
Hi,Walter

If you want to use AbstractTableModel .All methods in the interface must be implemented.
Usually,you need to provide three methods:


You have still second selection - consider to use DefaultTableModel.


Regards, Richard
Clivant Yeo
Ranch Hand

Joined: May 22, 2004
Posts: 124
Hi Walter,

You can also use the TableModel interface. Can have more customization.

Regards,
Clivant


Clivant Yeo
My Personal Website
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Questions on JTable