Possible Duplicate:
Java – repaint(x, y, w, h) doesn't call paintComponent? (with SSCCE)
I’m trying out this neato performance trick repaint(x, y, w, h) and it sure is helping performance a lot.
Unfortunately, the special extras I’ve put into a paintComponent in the same class are now not being painted. I put a System.out.println() test at the beginning of paintComponent and it turns out it’s not even called (as our astute readers probably were thinking from the beginning of this paragraph). When I use a plain repaint(), paintComponent() is called, no problem.
Specifically, I’ve got a JLabel, with a mouseListener, that on mouseEnter repaints the label.
What’s the deal? I hope I’m missing something and this is still possible? That extra performance sure is nice…
repaint()is actually a one-liner that callsrepaint(0, 0, width, height), so your basic thesis here — thatrepaint()with arguments is fundamentally different fromrepaint()without — is provably false. If I were a betting man, I’d bet that the arguments you’re passing to this method describe a region with zero area (i.e., width <= 0) and so theRepaintManageris simply ignoring the requests.You may be able to demonstrate this by changing the arguments to known good constant values, or maybe just
println()the values of the arguments before you pass them.