Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / General / May 2007

Tip: Looking for answers? Try searching our database.

Why does fireTableDataChanged cause getValueAt called repeatly?

Thread view: 
Allen - 05 May 2007 08:32 GMT
First update table model.
tableModel.addData()...

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

I found getValueAt called repeatly.
Is there anything wrong?
Tom Hawtin - 05 May 2007 10:24 GMT
> First update table model.
> tableModel.addData()...
[quoted text clipped - 4 lines]
> 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
Allen - 06 May 2007 13:09 GMT
> > First update table model.
> > tableModel.addData()...
[quoted text clipped - 10 lines]
>
> 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?
Tom Hawtin - 06 May 2007 13:41 GMT
> 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
Allen - 07 May 2007 03:32 GMT
> > The table just shows log items. When a new log comes up, it will be
> > inserted
[quoted text clipped - 8 lines]
>
> Tom Hawtin

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

>>>>>> Enter getValueAt, row = 0, col = 4
>>>>>> Enter getValueAt, row = 1, col = 0
[quoted text clipped - 15 lines]
>>>>>> Enter getValueAt, row = 0, col = 1
>>>>>> Enter getValueAt, row = 0, col = 2
.......................................................................
Tom Hawtin - 07 May 2007 04:19 GMT
> 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
Allen - 07 May 2007 04:43 GMT
> > Now I use fireTableRowInserted method. It also calls getValueAt
> > endlessly.
[quoted text clipped - 5 lines]
>
> 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!


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.