Why does fireTableDataChanged cause getValueAt called repeatly?

A

Allen

First update table model.
tableModel.addData()...

Then update table display.
tableModel.fireTableDataChanged()...

I found getValueAt called repeatly.
Is there anything wrong?
 
T

Tom Hawtin

Allen said:
First update table model.
tableModel.addData()...

Then update table display.
tableModel.fireTableDataChanged()...

I found getValueAt called repeatly.
Is there anything wrong?

You have fired the event that says that all the data in the table has
changed. Anything interested in the table data (for instance the JTable
rendering the data) will have to reread all the relevant data.

Tom Hawtin
 
A

Allen

You have fired the event that says that all the data in the table has
changed. Anything interested in the table data (for instance the JTable
rendering the data) will have to reread all the relevant data.

Tom Hawtin

Thank you!

The table just shows log items. When a new log comes up, it will be
inserted
at the first row. So I call fireTableDataChanged method.

How to avoid repeatly calling getValueAt?
 
T

Tom Hawtin

Allen said:
The table just shows log items. When a new log comes up, it will be
inserted
at the first row. So I call fireTableDataChanged method.

How to avoid repeatly calling getValueAt?

Using fireTableRowsInserted would produce a more precise event.

Probably the visible section of the table will be reread anyway. If it's
a performance problem, cache your table values.

Tom Hawtin
 
A

Allen

Using fireTableRowsInserted would produce a more precise event.

Probably the visible section of the table will be reread anyway. If it's
a performance problem, cache your table values.

Tom Hawtin

Now I use fireTableRowInserted method. It also calls getValueAt
endlessly.
I only add two rows into the table. Look these output message.
........................................................................
 
T

Tom Hawtin

Allen said:
Now I use fireTableRowInserted method. It also calls getValueAt
endlessly.
I only add two rows into the table. Look these output message.

Literally endlessly? Are you sure you are not causing the table model to
fire events from getValueAt or causing repaints/revalidates in some
other way?

Tom Hawtin
 
A

Allen

Literally endlessly? Are you sure you are not causing the table model to
fire events from getValueAt or causing repaints/revalidates in some
other way?

Tom Hawtin

Sorry. I found the reason now. I used my custermized multiline
textarea cell renderer.
And I just overrided getTableCellRendererComponent method of
TableCellRenderer interface.
Now I change to use TextAreaRenderer download from
http://www.javaspecialists.co.za/archive/newsletter.do?issue=106&locale=en_US.
It is ok now.

Thank you!
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,579
Members
45,053
Latest member
BrodieSola

Latest Threads

Top