Solved

size of image icons in button

Posted on 2004-09-30
14
188 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
Online Training Solution

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action. Forget about retraining and skyrocket knowledge retention rates.

 
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

Independent Software Vendors: 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

Suggested Solutions

Go is an acronym of golang, is a programming language developed Google in 2007. Go is a new language that is mostly in the C family, with significant input from Pascal/Modula/Oberon family. Hence Go arisen as low-level language with fast compilation…
Introduction This article is the second of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers the basic installation and configuration of the test automation tools used by…
Viewers will learn about basic arrays, how to declare them, and how to use them. Introduction and definition: Declare an array and cover the syntax of declaring them: Initialize every index in the created array: Example/Features of a basic arr…
This tutorial covers a practical example of lazy loading technique and early loading technique in a Singleton Design Pattern.
Suggested Courses

734 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