• Post Reply Bookmark Topic Watch Topic
  • New Topic

Picture as Button?  RSS feed

 
Scott Hanes
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I would like to know how to use a picture as a Button. Is it even possible? If so, could you show me where I can find code for it, or post some yourself.
The images will be on my computer.
Thanks.
 
Cp Baherwani
Ranch Hand
Posts: 41
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You can create a JButton and use setIcon method to set an image on it.
 
Nawar Gailani
Ranch Hand
Posts: 46
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
As Chandra said, use setIcon() method.
Example:


The redo.png image is in images directory which is relative path.
Hope this helps.
 
Jeff Albertson
Ranch Hand
Posts: 1780
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This recent thread may be useful: http://www.coderanch.com/t/342882/GUI/java/JButtons-not-buttons
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!