> >>>>Do you use EventQueue.invokeLater() to fill table?
> >>>
[quoted text clipped - 61 lines]
> >
> > Wes
> DataRecord is not private here.
Is that an issue?
> Where and how do you change data (DataRecord)?
In a separate thread the data are loaded into DataRecord. The number of
rows is increasing all the time (until all rows are retrieved from the
database). Other than that there are no changes to the data. It's simply a
program that retrieves some data and displays it in a JTable.
> Do you rebuild TableModel when new data arrived?
Rebuild? I fire that rows have been inserted but that is all. What do you
mean by rebuild?
> Why all methods are synchronized?
I saw this in an example so I thought that these methods had to be
synchronized.
Thanks,
Wes
Vova Reznik - 21 Oct 2005 19:09 GMT
If you don't want to get answer/help ....
>>DataRecord is not private here.
>
> Is that an issue?
It may be.
>>Where and how do you change data (DataRecord)?
>
[quoted text clipped - 6 lines]
> Rebuild? I fire that rows have been inserted but that is all. What do you
> mean by rebuild?
try fireTableDataChanged()
it should be something like:
when data ready
EventQueue.invokeLater(new Runnable(){
public void run(){
dr = new Dr;
model.fireTableDataChanged();
}
});
I will recomend you to have dr private
and one more method for your table model
public void loadDaata(DataRecord dr){
this.dr = dr;
super.fireTabelDataChanged();
}
and some where
public void dataArrived(final DataRecord dr){
EventQueue.invokeLater(new Runnable(){
public void run(){
model.loadData(dr);
}
});
}
and only if number of columns is static.
fireTableDataChanged and fireTableRowsInserted
work different.
remove synchronized - no needs
>>Why all methods are synchronized?
>
[quoted text clipped - 4 lines]
>
> Wes
Roedy Green - 21 Oct 2005 22:14 GMT
>In a separate thread the data are loaded into DataRecord.
But a TableModel must be in 100% in charge of the data. One of its
jobs it to notify Swing of the changes. If other threads are messing
with its data, it cannot do so.
The other thread must modify the data via a method of your TableModel.
JTables and TableModels are not thread safe, so typically you would
have that other thread do a little chunk of work at a time on the
Swing thread via SwingUtilities.invokeLater so as not to tie up the
Swing thread for long periods of time.
You could to that via a convenience method on your TableModel.

Signature
Canadian Mind Products, Roedy Green.
http://mindprod.com Again taking new Java programming contracts.