This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes Swing / AWT / SWT and the fly likes Painting over a image Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "Painting over a image" Watch "Painting over a image" New topic
Author

Painting over a image

Andy Woods
Greenhorn

Joined: Nov 29, 2001
Posts: 5
Hello,
Is it possible to paint over a background image? What I am trying to do is have a background image and only paint over a certain part (like a 5x5 pixel square) when an event happens. Also, the new painted over I would like to have a mouse over and display some information.
Or, should i create the main background graphic with spaces to place the painted section or a smaller 5x5 image?
Sorry for being cryptic of some sorts.. Just having a tough time following Java's Swing book for this..
Andy
woods_a@acadmn.mercer.edu
Nathan Pruett
Bartender

Joined: Oct 18, 2000
Posts: 4121

It's possible to paint over a background image... all you have to do is paint the background image first and then paint the new stuff later, so it will paint on top of the background. It sounds like the easiest thing for you to do is have an extended JPanel or JComponent that has a paintComponent() method that first paints the background, and then has some if/else statements to decide what overlays to paint. For the mouse-overs, all you have to do is add MouseMotionListeners to the component and check for the x,y location of the mouseevent to see if you need to do a mouse-over.

-Nate


-Nate
Write once, run anywhere, because there's nowhere to hide! - /. A.C.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Painting over a image
 
Similar Threads
avoiding flickering
How to set a Background that not stretch?
Component on Image
painting image over JButton
Creating a 'background'