Solved

Displaying images as Jbutton

Posted on 2010-11-08
7
591 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
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
Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

 
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

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

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

Entering a date in Microsoft Access can be tricky. A typo can cause month and day to be shuffled, entering the day only causes an error, as does entering, say, day 31 in June. This article shows how an inputmask supported by code can help the user a…
A short article about problems I had with the new location API and permissions in Marshmallow
Viewers will learn about the regular for loop in Java and how to use it. Definition: Break the for loop down into 3 parts: Syntax when using for loops: Example using a for loop:

829 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