This week's book giveaways are in the Java EE and JavaScript forums.
We're giving away four copies each of The Java EE 7 Tutorial Volume 1 or Volume 2(winners choice) and jQuery UI in Action and have the authors on-line!
See this thread and this one for details.
The moose likes Swing / AWT / SWT and the fly likes paintComponent JPanel Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "paintComponent JPanel" Watch "paintComponent JPanel" New topic
Author

paintComponent JPanel

Mathias Nilsson
Ranch Hand

Joined: Aug 21, 2004
Posts: 367
Hi!

I have a JPanel that overrides the paintComponent method. I paint a rule from -10 to 470 mm

I do not want to repaint the whole component but when the mouse moves I need to set a red marker where the mouse is in the rule. How can I do this whithout repainting the whole JPanel?


SCJP1.4
Craig Wood
Ranch Hand

Joined: Jan 14, 2004
Posts: 1535
Using an offscreen image for the unchanging part of the graphics and drawing the marker on
top of it (between the image and the user) is one standard way.
Mathias Nilsson
Ranch Hand

Joined: Aug 21, 2004
Posts: 367
Thanks!

I'll look into the code
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: paintComponent JPanel