Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

size of image icons in button

Posted on 2004-09-30
14
Medium Priority
?
190 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 1400 total points
ID: 12195499
Image i = icon.getImage();
Image scaled = i.getScaledInstance(width, height, Image.SCALE_SMOOTH);
ImageIcon resized = new ImageIcon(scaled);
0
The top UI technologies you need to be aware of

An important part of the job as a front-end developer is to stay up to date and in contact with new tools, trends and workflows. That’s why you cannot miss this upcoming webinar to explore the latest trends in UI technologies!

 
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

Technology Partners: 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!

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…
In this post we will learn how to make Android Gesture Tutorial and give different functionality whenever a user Touch or Scroll android screen.
This tutorial covers a step-by-step guide to install VisualVM launcher in eclipse.
This tutorial explains how to use the VisualVM tool for the Java platform application. This video goes into detail on the Threads, Sampler, and Profiler tabs.
Suggested Courses

670 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