size of image icons in button

Hi experts,

is there any way to set all my images on the buttons to a certain size?

thanks
SamooramadAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

CEHJCommented:
Haven't we been this way before ? ;-)
0
objectsCommented:
you'll need to resize them before assinging them to your buttons.
0
objectsCommented:
Image i = icon.getImage();
Image scaled = i.getScaledInstance(width, height, Image.SCALE_SMOOTH);
ImageIcon resized = new ImageIcon(scaled);
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Cloud Class® Course: Microsoft Azure 2017

Azure has a changed a lot since it was originally introduce by adding new services and features. Do you know everything you need to about Azure? This course will teach you about the Azure App Service, monitoring and application insights, DevOps, and Team Services.

CEHJCommented:
The last idea was to scale them before adding them i seem to remember ;-)
0
SamooramadAuthor Commented:
I dont know CEHJ.. I tend to forget :)
0
objectsCommented:
the above code will achieve what you require
0
SamooramadAuthor Commented:
ok will get back to you

hey if you guys have time to kill help me out with my printing question :)
0
objectsCommented:
> hey if you guys have time to kill

I wish :)
0
SamooramadAuthor Commented:
Image i = icon.getImage();

objects, got an error with this line..

 icon is not public in java.awt.Frame; cannot be accessed from outside package at line 33, column 13
I placed this line with my declarations..do I need to move it?
0
SamooramadAuthor Commented:
>>I wish :)

well :) ... anytime you can spare is always appritiated
0
objectsCommented:
replace icon with the variable name of your (inscaled) ImageIcon:
0
objectsCommented:

ImageIcon icon = new ImageIcon(...
Image i = icon.getImage();
Image scaled = i.getScaledInstance(width, height, Image.SCALE_SMOOTH);
ImageIcon resized = new ImageIcon(scaled);

0
SamooramadAuthor Commented:
worked like a charm
thaaaaaaank yoooooouu :)
0
objectsCommented:
no worries :)
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Java

From novice to tech pro — start learning today.