Solved

Displaying images as Jbutton

Posted on 2010-11-08
7
598 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
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
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 86

Expert Comment

by:CEHJ
ID: 34091436
0
 
LVL 1

Assisted Solution

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

Featured Post

Secure Your Active Directory - April 20, 2017

Active Directory plays a critical role in your company’s IT infrastructure and keeping it secure in today’s hacker-infested world is a must.
Microsoft published 300+ pages of guidance, but who has the time, money, and resources to implement? Register now to find an easier way.

Question has a verified solution.

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

Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
If you’re thinking to yourself “That description sounds a lot like two people doing the work that one could accomplish,” you’re not alone.
Viewers will learn one way to get user input in Java. Introduce the Scanner object: Declare the variable that stores the user input: An example prompting the user for input: Methods you need to invoke in order to properly get  user input:
With the power of JIRA, there's an unlimited number of ways you can customize it, use it and benefit from it. With that in mind, there's bound to be things that I wasn't able to cover in this course. With this summary we'll look at some places to go…

749 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