java /TableModel of Objects/Update Object"
Posted
by
Tomás Ó Briain
on Stack Overflow
See other posts from Stack Overflow
or by Tomás Ó Briain
Published on 2011-06-24T15:01:12Z
Indexed on
2011/06/24
16:22 UTC
Read the original article
Hit count: 202
I've a collection of Stock objects that I'm updating about 10/15 variables for in real-time. I'm accessing each Stock by its ID in the collection. I'm also trying to display this in a JTable and have implemented an AbstractTablemodel. It's not working too well.
I've a RowMap that I add each ID to as Stocks are added to the TableModel. To update the prices and variables of all the stocks in the TableModel, I want to send a Stock object to an updateModel(Stock s) method. I can find the relevant row by searching the map, but how do I handle this nicely, so I don't have to start iterating through table columns and comparing the values of the cells to the variables of the object to see whether there are any differences??
Basically, i want to send a Stock object to the TableModel and update cells if there are changes and do nothing if there aren't.
Any ideas about how to implement a TableModel that might do this? Any pointeres at all would be appreciated.
Thanks.
© Stack Overflow or respective owner