Insubstantial / insubstantial

Swing look-and-feel library and assorted widgets
193 stars 58 forks source link

JTable hover problems #62

Closed PirolA closed 12 years ago

PirolA commented 12 years ago

Hi shemnon,

if the mouse is moved over the table, the current row is highlighted. At the first glance everything is ok.

I have added logging to the method JTable#paintComponent(Graphics), so that I can see how often the table is redrawn and the corresponding renderers (i have expensive renderers ;( ) are called.

Every time I change to another row, the table is redrawn about 15 times, no matter how many data is in the table.

If I do not use Substance and self-programming the highlight of table rows, the table only drawn once, as expected. I think this is a bug, I'd be very grateful if you could deal with it.

I can provide two test classes to identify what the problem is.

Greetings and best compliment to the great work, Pirol

I am using version 7.0 !

Addition: If you hover over the table. for 5 seconds the CPU increase to 100% ;(

PirolA commented 12 years ago

Ido not have permissons to reopen Issue #24, so I create a new Issue.

shemnon commented 12 years ago

please submit the test case

PirolA commented 12 years ago

Run the Check.java class and switch to the Table tab, when you move the mouse over the table up and down the cpu usage increase.

shemnon commented 12 years ago

can you submit the second test case you mentioned you had?

shemnon commented 12 years ago

Did some digging. Like I suspected the calls are relating to animation. So this is compounding the fact your table cell renderers take a while to calculate. IMHO the slow renderers are more the problem than the animation. But there is an escape hatch built into the animation code. You can turn off animation for specific components or classes. This snippit turns of the 4 types of animations a specific table can see:

    AnimationConfigurationManager.getInstance().disallowAnimations(AnimationFacet.FOCUS_LOOP_ANIMATION, table);
    AnimationConfigurationManager.getInstance().disallowAnimations(AnimationFacet.SELECTION, table);
    AnimationConfigurationManager.getInstance().disallowAnimations(AnimationFacet.ROLLOVER, table);
    AnimationConfigurationManager.getInstance().disallowAnimations(AnimationFacet.ICON_GLOW, table);

You can also turn off animations for all tables by replacing table with JTable.class.

Because this animation of the renderers and is compounding a practice that shouldn't be done (table cell renderers should be low to no calculations, or cached) and the fact an escape hatch exists, I am closing this as 'wont fix'