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?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
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
Mick BarryJava DeveloperCommented:
you'll need to resize them before assinging them to your buttons.
0
Mick BarryJava DeveloperCommented:
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
OWASP Proactive Controls

Learn the most important control and control categories that every architect and developer should include in their projects.

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
Mick BarryJava DeveloperCommented:
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
Mick BarryJava DeveloperCommented:
> 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
Mick BarryJava DeveloperCommented:
replace icon with the variable name of your (inscaled) ImageIcon:
0
Mick BarryJava DeveloperCommented:

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
Mick BarryJava DeveloperCommented:
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.