This week's book giveaway is in the Servlets forum.
We're giving away four copies of Murach's Java Servlets and JSP and have Joel Murach on-line!
See this thread for details.
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


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
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: 2152
    
    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.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: How to place image on JButton
 
Similar Threads
jbutton background image
Image is not been added to a label
repaint problems DDRAW.DLL
Passing images to an applet with getParameter.
painting image over JButton