File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
The moose likes Swing / AWT / SWT and the fly likes BufferedImage to Icon - have I done this in the correct way? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Soft Skills this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "BufferedImage to Icon - have I done this in the correct way?" Watch "BufferedImage to Icon - have I done this in the correct way?" New topic
Author

BufferedImage to Icon - have I done this in the correct way?

krillian konstatos
Ranch Hand

Joined: Jan 03, 2011
Posts: 49

hi, forumsts!

I have had big problem width image handling in java. I am having a project where i must create
thumbnail images in JButton objects and when the user click on theese buttons a maximized
undecorated frame is opened and displays a larger variant of the selected image / images.
I have rendered the thumbnail images to icons for the button objects using the getScaledInstance
method in the Image class. But i am still unsure of if i have the grip on this operation or not.
I first assign a thumbnail image to a label in large frame and in an filterIcon method i convert
the image from that icon label to an object using the BufferedImage class and create a larger
icon image for my label object. I must also consider the size of the selected image to that part
that i dont want to display images that are smaller than the width of 800 pixels to be displayed
all over the screen but half of that size. Images that are larger than 800 will be displayed over
the screen with their defalt sizes. I have the code below ...







I just need some hints or tips how to do this correct i am a rookie and i know i must have missed out a lot.
I have read some articles on the subjects in question but i am still unsure. I hope i have been clear enough
in my description of the problem in this post.

Best regards,
Krillian.
Randall Twede
Ranch Hand

Joined: Oct 21, 2000
Posts: 4347
    
    2

one way to look at it is "if it works it is correct"
as far as style, i am no expert, and i only skimmed through your code, but it looks pretty good in general


SCJP
Visit my download page
krillian konstatos
Ranch Hand

Joined: Jan 03, 2011
Posts: 49

Randall Twede wrote:one way to look at it is "if it works it is correct"
as far as style, i am no expert, and i only skimmed through your code, but it looks pretty good in general


Thank you so much for your reply and it works fine for the project in question and thank you so much for your
compliment on the style. It sheared me up a little after a lot of struggling with java's graphic handling
packages and thumbnail image processing.

/krillian.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: BufferedImage to Icon - have I done this in the correct way?