JXTable high cpu when visible

37 Views Asked by At

I'm debugging legacy code that displays a small amount data (< 100 entries) using a JXTable. All the functionality works but when there is at least one entry in the table, the CPU usage climbs to over 95% iff the pane is displayed. Instrumentation has shown that the highlight method is called several times per millisecond. The highlight method is called only when the table is visible (a different tab is selected), which makes sense. I am in the process of trying to duplicate it in a small sample, but that's not working yet. I just wondered if anyone out there has seen similar behavior and came up with a solution. Library: swingx-1.0.jar Java: jdk1.8.0_144

1

There are 1 best solutions below

0
AlexHomeBrew On

This was my* code. In the cellRenderer() there was a call to setRowHeight(). This causes the pane to be marked dirty. So the next cycle, it does a repaint(). The repaint() calls my cellRenderer(). Thus creating a repaint loop whenever the pane is visible. The solution was to remove the call to setRowHeight() since it wasn't needed anyway. *I say my code because I am now responsible for it. This problem was created long before I joined the company.