This week's book giveaway is in the OO, Patterns, UML and Refactoring forum.
We're giving away four copies of Refactoring for Software Design Smells: Managing Technical Debt and have Girish Suryanarayana, Ganesh Samarthyam & Tushar Sharma on-line!
See this thread 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

JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "paintComponent JPanel" Watch "paintComponent JPanel" New topic

paintComponent JPanel

Mathias Nilsson
Ranch Hand

Joined: Aug 21, 2004
Posts: 367

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?

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

I'll look into the code
I’ve looked at a lot of different solutions, and in my humble opinion Aspose is the way to go. Here’s the link:
subject: paintComponent JPanel
jQuery in Action, 3rd edition