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 Changing background images Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "Changing background images" Watch "Changing background images" New topic

Changing background images

rahulash sharma

Joined: Jan 05, 2009
Posts: 15
I am new to Swing. I am preparing a application in which i am displaying a image in panel. I want to add a functionality in which if i click on that image then background image change.
How can i do that .Please help.
Thanks in advance
Maneesh Godbole
Saloon Keeper

Joined: Jul 26, 2007
Posts: 10744

In case you haven't done so, check out this example on displaying background images

So when you want to change the image,
1) assign the new image to the image instance
2) Call a revalidate and repaint on the panel so it will start displaying the new image.

[How to ask questions] [Donate a pint, save a life!] [Onff-turn it on!]
I agree. Here's the link:
subject: Changing background images
It's not a secret anymore!