GeeCON Prague 2014*
The moose likes Swing / AWT / SWT and the fly likes How to place image on JButton Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "How to place image on JButton" Watch "How to place image on JButton" New topic
Author

How to place image on JButton

Ashish Gundewad
Greenhorn

Joined: Oct 10, 2010
Posts: 14
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

Joined: Jun 13, 2009
Posts: 2191
    
    7
Not sure if .bmp files are supported. Try a .jpg or .gif.
Ashish Gundewad
Greenhorn

Joined: Oct 10, 2010
Posts: 14
Its working in .jpg format.
Thanks Rob.
 
GeeCON Prague 2014
 
subject: How to place image on JButton