This week's book giveaway is in the JavaScript forum.
We're giving away four copies of Cross-Platform Desktop Applications: Using Node, Electron, and NW.js and have Paul Jensen on-line!
See this thread for details.
Win a copy of Cross-Platform Desktop Applications: Using Node, Electron, and NW.js this week in the JavaScript forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Changing background images  RSS feed

 
rahulash sharma
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello
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
Bartender
Posts: 11445
18
Android Eclipse IDE Google Web Toolkit Java Mac Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In case you haven't done so, check out this example on displaying background images
http://faq.javaranch.com/java/BackgroundImageOnJPanel

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.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!