File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How to place image on JButton

 
Ashish Gundewad
Greenhorn
Posts: 14
AngularJS Java Spring
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello,
I want to place an image on JButton.
I am creating a object of ImageIcon and passing it to JButton like

JButton myJButton = new JButton("JButton", ImgObj);

The image is of .bmp format.
But i am not able to get image on the button.
Have I done any mistake.
Please help me.
Thanks..
 
Rob Camick
Ranch Hand
Posts: 2475
8
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Not sure if .bmp files are supported. Try a .jpg or .gif.
 
Ashish Gundewad
Greenhorn
Posts: 14
AngularJS Java Spring
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Its working in .jpg format.
Thanks Rob.
 
Don't get me started about those stupid light bulbs.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic