This week's book giveaway is in the OCAJP forum.
We're giving away four copies of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) and have Khalid A Mughal & Rolf W Rasmussen on-line!
See this thread for details.
Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How to place image on JButton

 
Ashish Gundewad
Greenhorn
Posts: 14
AngularJS Java Spring
  • 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: 2608
9
  • 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
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Its working in .jpg format.
Thanks Rob.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic