Avatar of hipal
hipalFlag for United States of America asked on

Image as a JButton

I am still not able to  make a image a JButton after all the help in previous post.

Thanks to my poor Java Knowledge.

Can some one please help more on this ? May be some little code snippet.

I am trying to make a image act as a JButton and not to insert a image in a button.

Thanks !
ProgrammingJava

Avatar of undefined
Last Comment
Mick Barry

8/22/2022 - Mon
ksivananth

Mick Barry

thats going to be a fair bit of work to do properly.
far easier to use existing JButton class
CEHJ

Can you attach an image you'd like to use?
This is the best money I have ever spent. I cannot not tell you how many times these folks have saved my bacon. I learn so much from the contributors.
rwheeler23
ASKER
hipal

Thanks everyone.

@CEHJ, Please find the pic attached. Or you can just use any pic.

I have to make a lot of buttons using different pics.
pic.png
ASKER CERTIFIED SOLUTION
ksivananth

Log in or sign up to see answer
Become an EE member today7-DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform
Sign up - Free for 7 days
or
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.
See how we're fighting big data
Not exactly the question you had in mind?
Sign up for an EE membership and get your own personalized solution. With an EE membership, you can ask unlimited troubleshooting, research, or opinion questions.
ask a question
SOLUTION
Log in to continue reading
Log In
Sign up - Free for 7 days
Get an unlimited membership to EE for less than $4 a week.
Unlimited question asking, solutions, articles and more.
CEHJ

>>you can simply use JButton/JLabel and set this as icon with empty border

An empty border isn't sufficient actually
ASKER
hipal

yes, we need to set the contentfillarea too .. :(

I just realized that ksiv.suggested just to make border zero ..

Anyways ....
Get an unlimited membership to EE for less than $4 a week.
Unlimited question asking, solutions, articles and more.
Mick Barry

that what I had already suggested ;)