The moose likes Developer Certification (SCJD/OCMJD) and the fly likes how to update table after search Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Developer Certification (SCJD/OCMJD)
Bookmark "how to update table after search" Watch "how to update table after search" New topic
Author

how to update table after search

Varaku Venkata
Ranch Hand

Joined: Mar 17, 2002
Posts: 30
Hi
can somebody tell me how to update table after a search button is pressed. I am using AbstactTableModel for my JTable.
Thanks
venkat
raphael Bereh
Ranch Hand

Joined: Jan 15, 2002
Posts: 79
Use
fireTableDataChanged() or one of the fireXXX methods of AbstractTableModel.


SCJP,SCJD,SCBCD
Varaku Venkata
Ranch Hand

Joined: Mar 17, 2002
Posts: 30
Hi Raphael,
can you explain in some more detail..
Thanks for replying...
Adam Roberts
Ranch Hand

Joined: Mar 18, 2002
Posts: 71
Heres how I did it,
I have class that extends JPanel displaying results. It has a method that takes an array of DataInfo[] and sets the result accordingly. The class that searches the DB recieves a reference of this and calls the method
Hope that isnt too confusing


Adam Roberts - SCJP2, SCJD<br />insert witty something here
raphael Bereh
Ranch Hand

Joined: Jan 15, 2002
Posts: 79
Well,
When you implement the AbstractTableModel, the method getValueAt tells you table model which Vector or Array of Strings to use for the Table Data. So like in Observer/Observable, the way you notify any changes to the table model is by using the fireXXX methods (instead of setChanged(); notifyObservers()
Hope this helps
Varaku Venkata
Ranch Hand

Joined: Mar 17, 2002
Posts: 30
Thanks Robert and Raphael,
I have used fireTableUpdated method and was able to update the table with the new row values..
Have a Nice Day
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: how to update table after search