Solved

size of image icons in button

Posted on 2004-09-30
14
189 Views
Last Modified: 2010-03-31
Hi experts,

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

thanks
0
Comment
Question by:Samooramad
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 7
  • 5
  • 2
14 Comments
 
LVL 86

Expert Comment

by:CEHJ
ID: 12195385
Haven't we been this way before ? ;-)
0
 
LVL 92

Expert Comment

by:objects
ID: 12195489
you'll need to resize them before assinging them to your buttons.
0
 
LVL 92

Accepted Solution

by:
objects earned 350 total points
ID: 12195499
Image i = icon.getImage();
Image scaled = i.getScaledInstance(width, height, Image.SCALE_SMOOTH);
ImageIcon resized = new ImageIcon(scaled);
0
Salesforce Has Never Been Easier

Improve and reinforce salesforce training & adoption using WalkMe's digital adoption platform. Start saving on costly employee training by creating fast intuitive Walk-Thrus for Salesforce. Claim your Free Account Now

 
LVL 86

Expert Comment

by:CEHJ
ID: 12195501
The last idea was to scale them before adding them i seem to remember ;-)
0
 

Author Comment

by:Samooramad
ID: 12195525
I dont know CEHJ.. I tend to forget :)
0
 
LVL 92

Expert Comment

by:objects
ID: 12195530
the above code will achieve what you require
0
 

Author Comment

by:Samooramad
ID: 12195544
ok will get back to you

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

Expert Comment

by:objects
ID: 12195569
> hey if you guys have time to kill

I wish :)
0
 

Author Comment

by:Samooramad
ID: 12195588
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
 

Author Comment

by:Samooramad
ID: 12195619
>>I wish :)

well :) ... anytime you can spare is always appritiated
0
 
LVL 92

Expert Comment

by:objects
ID: 12195620
replace icon with the variable name of your (inscaled) ImageIcon:
0
 
LVL 92

Expert Comment

by:objects
ID: 12195627

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

0
 

Author Comment

by:Samooramad
ID: 12195682
worked like a charm
thaaaaaaank yoooooouu :)
0
 
LVL 92

Expert Comment

by:objects
ID: 12195689
no worries :)
0

Featured Post

Salesforce Has Never Been Easier

Improve and reinforce salesforce training & adoption using WalkMe's digital adoption platform. Start saving on costly employee training by creating fast intuitive Walk-Thrus for Salesforce. Claim your Free Account Now

Question has a verified solution.

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

By the end of 1980s, object oriented programming using languages like C++, Simula69 and ObjectPascal gained momentum. It looked like programmers finally found the perfect language. C++ successfully combined the object oriented principles of Simula w…
Java Flight Recorder and Java Mission Control together create a complete tool chain to continuously collect low level and detailed runtime information enabling after-the-fact incident analysis. Java Flight Recorder is a profiling and event collectio…
Video by: Michael
Viewers learn about how to reduce the potential repetitiveness of coding in main by developing methods to perform specific tasks for their program. Additionally, objects are introduced for the purpose of learning how to call methods in Java. Define …
This tutorial covers a practical example of lazy loading technique and early loading technique in a Singleton Design Pattern.

623 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