Solved

size of image icons in button

Posted on 2004-09-30
14
187 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
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
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

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
xampp tool 12 58
Can anyone please tell me why i can not find ID  investorCoolGrid inside the jsp page? 1 23
jboss 7.1 start up error 1 61
hashmap order 17 40
After being asked a question last year, I went into one of my moods where I did some research and code just for the fun and learning of it all.  Subsequently, from this journey, I put together this article on "Range Searching Using Visual Basic.NET …
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 learn about the “for” loop and how it works in Java. By comparing it to the while loop learned before, viewers can make the transition easily. You will learn about the formatting of the for loop as we write a program that prints even numbers…
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 …

756 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