Solved

Displaying images as Jbutton

Posted on 2010-11-08
7
611 Views
Last Modified: 2012-06-27
Hi All,

Can someone please suggest how can I make my images to be a button?

I am trying to show just an image and no borders etc. and want it to work as button.

Thanks!
0
Comment
Question by:hipal
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
7 Comments
 

Author Comment

by:hipal
ID: 34090214
I am not trying to display a picture in JButton but trying to make an image itself a button.
0
 
LVL 92

Accepted Solution

by:
objects earned 125 total points
ID: 34090262
you can use an image as a JButton icon
then you need to remove all extra painting round the edges. Look for a look and feel that supports that (or write your own)
you could also try subclassing and overriding paintComponent()/paint()
0
 

Author Comment

by:hipal
ID: 34090598
Can you please give a very simple example overriding paintCOmponent to replace a circle as a button.

Hope I am not asking for too much. It that needs too much code, please ignore ..

thank you !
0
Optimize your web performance

What's in the eBook?
- Full list of reasons for poor performance
- Ultimate measures to speed things up
- Primary web monitoring types
- KPIs you should be monitoring in order to increase your ROI

 
LVL 26

Assisted Solution

by:ksivananth
ksivananth earned 125 total points
ID: 34090706
check this for creating round button, http://www.javanb.com/java/2/19561.html
0
 
LVL 16

Assisted Solution

by:Valeri
Valeri earned 125 total points
ID: 34090899
you can extend AbstractButton and to paint exactly what you need /in other words only the image/
Also you can use the JButton without border and set only image in it. like in this example :
http://www.esus.com/javaindex/j2se/jdk1.2/javaxswing/atomiccontrols/jbutton/jbuttonnoborder.html
0
 
LVL 1

Assisted Solution

by:GenroseSusai
GenroseSusai earned 125 total points
ID: 34093610
0

Featured Post

Salesforce Has Never Been Easier

Improve and reinforce salesforce training & adoption using WalkMe's digital adoption platform. Start saving on costly employee training by creating fast intuitive Walk-Thrus for Salesforce. Claim your Free Account Now

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In this post we will learn how to connect and configure Android Device (Smartphone etc.) with Android Studio. After that we will run a simple Hello World Program.
Today, the web development industry is booming, and many people consider it to be their vocation. The question you may be asking yourself is – how do I become a web developer?
Progress
Starting up a Project
Suggested Courses

631 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question