Solved

size of image icons in button

Posted on 2004-09-30
14
184 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
  • 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
 
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
Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

 
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

Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

Join & Write a Comment

Suggested Solutions

INTRODUCTION Working with files is a moderately common task in Java.  For most projects hard coding the file names, using parameters in configuration files, or using command-line arguments is sufficient.   However, when your application has vi…
Java contains several comparison operators (e.g., <, <=, >, >=, ==, !=) that allow you to compare primitive values. However, these operators cannot be used to compare the contents of objects. Interface Comparable is used to allow objects of a cl…
Viewers will learn about the regular for loop in Java and how to use it. Definition: Break the for loop down into 3 parts: Syntax when using for loops: Example using a for loop:
Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …

758 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

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now