Why is this JLabel continuously repainting?
Posted
by Morinar
on Stack Overflow
See other posts from Stack Overflow
or by Morinar
Published on 2010-05-07T20:08:23Z
Indexed on
2010/05/07
20:38 UTC
Read the original article
Hit count: 289
I've got an item that appears to continuously repaint when it exists, causing the CPU to spike whenever it is in any of my windows. It directly inherits from a JLabel, and unlike the other JLabels on the screen, it has a red background and a border. I have NO idea why it would be different enough to continuously repaint. The callstack looks like this:
Thread [AWT-EventQueue-1] (Suspended (breakpoint at line 260 in sItem))
sItem.paint(Graphics) line: 260
sItem(JComponent).paintToOffscreen(Graphics, int, int, int, int, int, int) line: 5124
RepaintManager$PaintManager.paintDoubleBuffered(JComponent, Image, Graphics, int, int, int, int) line: 1475
RepaintManager$PaintManager.paint(JComponent, JComponent, Graphics, int, int, int, int) line: 1406
RepaintManager.paint(JComponent, JComponent, Graphics, int, int, int, int) line: 1220
sItem(JComponent)._paintImmediately(int, int, int, int) line: 5072
sItem(JComponent).paintImmediately(int, int, int, int) line: 4882
RepaintManager.paintDirtyRegions(Map<Component,Rectangle>) line: 803
RepaintManager.paintDirtyRegions() line: 714
RepaintManager.seqPaintDirtyRegions() line: 694 [local variables unavailable]
SystemEventQueueUtilities$ComponentWorkRequest.run() line: 128
InvocationEvent.dispatch() line: 209
summitEventQueue(EventQueue).dispatchEvent(AWTEvent) line: 597
summitEventQueue(SummitHackableEventQueue).dispatchEvent(AWTEvent) line: 26
summitEventQueue.dispatchEvent(AWTEvent) line: 62
EventDispatchThread.pumpOneEventForFilters(int) line: 269
EventDispatchThread.pumpEventsForFilter(int, Conditional, EventFilter) line: 184
EventDispatchThread.pumpEventsForHierarchy(int, Conditional, Component) line: 174
EventDispatchThread.pumpEvents(int, Conditional) line: 169
EventDispatchThread.pumpEvents(Conditional) line: 161
EventDispatchThread.run() line: 122 [local variables unavailable]
It basically just continually hits that over and over again as fast as I can press continue. The code that is "unique" to this particular label looks approximately like this:
bgColor = OurColors.clrWindowTextAlert;
textColor = Color.white;
setBackground(bgColor);
setOpaque(true);
setSize(150, getHeight());
Border border_warning = BorderFactory.createCompoundBorder(
BorderFactory.createMatteBorder(1, 1, 1, 1, OurColors.clrXBoxBorder),
Global.border_left_margin);
setBorder(border_warning);
It obviously does more, but that particular block only exists for these labels that are causing the spike/continuous repaint.
Any ideas why it would keep repainting this particular label?
© Stack Overflow or respective owner