Skip to main content

getListCellRendererComponent called MANY times..

Please note these java.net forums are being decommissioned and use the new and improved forums at https://community.oracle.com/community/java.
1 reply [Last post]
gazyboy
Offline
Joined: 2011-02-08

Hi guys,
Im using a custom renderer for a list, ive found that the slowdown im experiencing is from a huge amount of calls to getListCellRendererComponent(),

As you can see here just entering the list it calls repaint 8 or 9 times, why is it doing this? its slowing everything right down.. each call can take up to 20ms!
TEST TOOK: 17 ms [unselectItem.setData INDEX:0]
TEST TOOK: 7 ms [unselectItem.setData INDEX:1]
TEST TOOK: 7 ms [unselectItem.setData INDEX:2]
TEST TOOK: 6 ms [unselectItem.setData INDEX:3]
TEST TOOK: 6 ms [unselectItem.setData INDEX:4]
TEST TOOK: 16 ms [selectItem.setData INDEX:0]
TEST TOOK: 9 ms [unselectItem.setData INDEX:0]
TEST TOOK: 7 ms [unselectItem.setData INDEX:1]
TEST TOOK: 6 ms [unselectItem.setData INDEX:2]
TEST TOOK: 6 ms [unselectItem.setData INDEX:3]
TEST TOOK: 7 ms [unselectItem.setData INDEX:4]
TEST TOOK: 6 ms [selectItem.setData INDEX:0]
TEST TOOK: 8 ms [unselectItem.setData INDEX:0]
TEST TOOK: 5 ms [selectItem.setData INDEX:0]
TEST TOOK: 29 ms [unselectItem.setData INDEX:0]
TEST TOOK: 28 ms [unselectItem.setData INDEX:1]
TEST TOOK: 31 ms [unselectItem.setData INDEX:2]
TEST TOOK: 28 ms [unselectItem.setData INDEX:3]
TEST TOOK: 28 ms [unselectItem.setData INDEX:4]
TEST TOOK: 23 ms [selectItem.setData INDEX:0]
TEST TOOK: 25 ms [unselectItem.setData INDEX:0]
TEST TOOK: 26 ms [unselectItem.setData INDEX:1]
TEST TOOK: 25 ms [unselectItem.setData INDEX:2]
TEST TOOK: 24 ms [unselectItem.setData INDEX:3]
TEST TOOK: 24 ms [unselectItem.setData INDEX:4]
TEST TOOK: 19 ms [selectItem.setData INDEX:0]
TEST TOOK: 24 ms [unselectItem.setData INDEX:0]
TEST TOOK: 24 ms [unselectItem.setData INDEX:1]
TEST TOOK: 22 ms [unselectItem.setData INDEX:2]
TEST TOOK: 22 ms [unselectItem.setData INDEX:3]
TEST TOOK: 22 ms [unselectItem.setData INDEX:4]
TEST TOOK: 21 ms [selectItem.setData INDEX:0]
TEST TOOK: 19 ms [selectItem.setData INDEX:1]
TEST TOOK: 18 ms [selectItem.setData INDEX:2]
TEST TOOK: 18 ms [selectItem.setData INDEX:3]
TEST TOOK: 18 ms [selectItem.setData INDEX:4]
TEST TOOK: 25 ms [unselectItem.setData INDEX:1]
TEST TOOK: 22 ms [unselectItem.setData INDEX:2]
TEST TOOK: 22 ms [unselectItem.setData INDEX:3]
TEST TOOK: 22 ms [unselectItem.setData INDEX:4]
TEST TOOK: 22 ms [unselectItem.setData INDEX:5]
TEST TOOK: 22 ms [unselectItem.setData INDEX:6]
TEST TOOK: 25 ms [unselectItem.setData INDEX:1]
TEST TOOK: 26 ms [unselectItem.setData INDEX:2]
TEST TOOK: 26 ms [unselectItem.setData INDEX:3]
TEST TOOK: 26 ms [unselectItem.setData INDEX:4]
TEST TOOK: 26 ms [unselectItem.setData INDEX:5]
TEST TOOK: 26 ms [unselectItem.setData INDEX:6]

Even moving up or down list causes calls to the list twice:
TEST TOOK: 21 ms [unselectItem.setData INDEX:0]
TEST TOOK: 15 ms [unselectItem.setData INDEX:2]
TEST TOOK: 16 ms [unselectItem.setData INDEX:3]
TEST TOOK: 16 ms [unselectItem.setData INDEX:4]
TEST TOOK: 17 ms [unselectItem.setData INDEX:5]
TEST TOOK: 16 ms [unselectItem.setData INDEX:6]
TEST TOOK: 15 ms [unselectItem.setData INDEX:0]
TEST TOOK: 16 ms [unselectItem.setData INDEX:2]
TEST TOOK: 17 ms [unselectItem.setData INDEX:3]
TEST TOOK: 17 ms [unselectItem.setData INDEX:4]
TEST TOOK: 17 ms [unselectItem.setData INDEX:5]
TEST TOOK: 18 ms [unselectItem.setData INDEX:6]

Can anyone tell me how to minimise these calls???
Thank in advance!
Gaz.

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
vprise
Offline
Joined: 2003-11-07

It does it for performance:
http://lwuit.blogspot.com/2008/07/lwuit-list-renderer-by-chen-fishbein.html
http://lwuit.blogspot.com/2008/08/model-mvc-million-contacts-march.html
Your list rendering code MUST be really fast and stateless to allow really large lists, I'm guessing you are triggering revalidates either explicitly or by using text areas without explicitly defining rows/columns etc.