We help IT Professionals succeed at work.

Reducing image size in a combobox for proper fitting and/or to my specification

Vanavah Edwards
on
How to reduce an image size in a combobox for proper fitting and/or to my specification
Comment
Watch Question

Awarded 2011
Awarded 2011
Commented:

Author

Commented:
I am reviewing them now.

Author

Commented:
I review all the others but the easiest one with the least code that worked in my class is the first one.
http://stackoverflow.com/questions/2856480/resizing-a-imageicon-in-a-jbutton
Only 3 lines of code below.  There is one point to consider, when you reduce the image size the comboxbox if set to a particular size will remain bigger than the image.  To make the combobox the same size as the image automatically set the  "renderer.setPreferredSize(null);" to null for the combobox.
Thank you very much you have been so helpful and save me alot of time.  I appreciate your efforts.  I will now award you and put some more quesitions out.
Image img = images[i].getImage();   
Image newimg = img.getScaledInstance(50,50, java.awt.Image.SCALE_SMOOTH); // where 50,50 is the width,height
images[i] = new ImageIcon(newimg);

Open in new window

Awarded 2011
Awarded 2011

Commented:
Great!
You are always welcome.