Results 1 to 6 of 6
Thread: How to use image as button
- 01-08-2012, 09:36 PM #1
Member
- Join Date
- Jan 2012
- Posts
- 10
- Rep Power
- 0
How to use image as button
I'm trying to design screen as specified. i searched a lot but didn't found proper help.
I'm beginner in java so please explain me the simplest way. the images used are in .png format & are transparent. i looks very bad when used over jbutton so i want to use those images work as buttons. If not possible, can we have links through those images? how? which way will be simpler? (by clicking these images, i want to open new frames. please tell me how to do that..)
Thank you.
Last edited by mangesh.gho; 01-08-2012 at 09:44 PM.
- 01-08-2012, 10:24 PM #2
Re: How to use image as button
Look at using Mouse listeners. If you know where your images are, you can map the mouse click's location to an image. You would need to build a list of where the shapes are located that you could search with the mouse click's location.by clicking these images, i want to
- 01-09-2012, 12:28 AM #3
Senior Member
- Join Date
- Jul 2009
- Posts
- 1,143
- Rep Power
- 5
Re: How to use image as button
You can add an image to a button. Then you can use:
button.setBorderPainted(false);
button.setContentAreaFilled(false);
- 01-09-2012, 12:40 AM #4
Re: How to use image as button
Do you want rectangular areas to click on?
Or do you want to be able to click on the shape of the images?
Can buttons have non-rectangular areas for clicking?
- 01-09-2012, 05:50 AM #5
Member
- Join Date
- Jan 2012
- Posts
- 10
- Rep Power
- 0
Re: How to use image as button
Actually it would be better if i could implement button with shape of that image but i don't want to make this thing complicated so if those two methods mentioned above, does the required job then i 'll be fine for me.. Any other suggestions?
- 01-09-2012, 06:02 AM #6
Senior Member
- Join Date
- Jul 2009
- Posts
- 1,143
- Rep Power
- 5
Re: How to use image as button
I guess you didn't check out my suggestion in this posting: Custom JButton :-)Can buttons have non-rectangular areas for clicking?
The easy part is using the button. The hard part is implementing the Shape to use for click detection.Actually it would be better if i could implement button with shape of that image but i don't want to make this thing complicated
Did you actually try using a button? It will be rectangular like the first suggestion unless you override the contains() method as I suggested.Any other suggestions?
Similar Threads
-
Hide a button but keep the image?
By Rtme in forum AWT / SwingReplies: 13Last Post: 06-05-2011, 05:05 PM -
Make a button class that uses your button image.
By eLancaster in forum New To JavaReplies: 1Last Post: 04-26-2011, 11:32 AM -
button displays image
By hopelessnoob in forum AWT / SwingReplies: 2Last Post: 03-12-2011, 03:44 PM -
AWT button image
By timkd127 in forum AWT / SwingReplies: 2Last Post: 03-01-2010, 04:41 AM -
Set focus on image button in swt
By diva_garg in forum New To JavaReplies: 3Last Post: 08-18-2008, 12:27 PM


1Likes
LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks