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
Asked
Active
Viewed 35 times
0
-
Back working on this. It is NOT a JXTable issue. I replaced the JXTable with a JTable and the issue remains. So there is something in the code that is doing this (and probably not a Swing problem). Debugging indicates that repaint() is called far too often when the pane is visible. I found one place where it was called by our code too often and when I coalesced them, it reduced the CPU usage by about a half. It still is behaving far too CPU intensive, but it is not a JXTable issue. – AlexHomeBrew Oct 02 '19 at 17:24
1 Answers
0
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.

AlexHomeBrew
- 117
- 9