Forums Register Login

Painting over a image

+Pie Number of slices to send: Send
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
+Pie Number of slices to send: Send
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
Have you no shame? Have you no decency? Have you no tiny ad?
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com


reply
reply
This thread has been viewed 1060 times.
Similar Threads
Component on Image
How to set a Background that not stretch?
avoiding flickering
Creating a 'background'
painting image over JButton
More...

All times above are in ranch (not your local) time.
The current ranch time is
Mar 29, 2024 00:07:05.