This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes Swing / AWT / SWT and the fly likes Displaying GIF/PNG image files in a Java Swing application Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "Displaying GIF/PNG image files in a Java Swing application" Watch "Displaying GIF/PNG image files in a Java Swing application" New topic
Author

Displaying GIF/PNG image files in a Java Swing application

Salman Ahmed
Greenhorn

Joined: Mar 18, 2008
Posts: 27
(I tried searching for this topic through the archives but was unable to find a clear answer to my question, so please bear with me!)

I have this Java Swing application in which I need to display image files - GIF, PNG, and JPEG initially. TIFF (and optionally PDF) will be dealt with later on. The image files will be retrieved from a server application and even at their smallest size will be 640x480 pixels. All image manipulations (rotation, zoom in, zoom out, etc.) will be done by the server so all my application has to do is just display the retrieved image file.

What container or component should I use for this purpose? I would prefer to make this container/component be scrollable by putting it inside a JScrollPane . Or if there are other better ways to make such a displayed image scrollable, please let me know.

Lastly, would I need to use the Java 2D API to display/render the image files or would I need to look at some other API/library?

I am using Java 1.5 and Swing.

Thanks!
Brian Cole
Author
Ranch Hand

Joined: Sep 20, 2005
Posts: 862
Originally posted by Salman Ahmed:
I have this Java Swing application in which I need to display image files - GIF, PNG, and JPEG initially. TIFF (and optionally PDF) will be dealt with later on. The image files will be retrieved from a server application and even at their smallest size will be 640x480 pixels. All image manipulations (rotation, zoom in, zoom out, etc.) will be done by the server so all my application has to do is just display the retrieved image file.

What container or component should I use for this purpose? I would prefer to make this container/component be scrollable by putting it inside a JScrollPane .


ImageIcon is part of Swing and can handle GIF, PNG, and JPEG.

Showing an image in a scroll pane can be as easy as
new JScrollPane(new JLabel(new ImageIcon(...))).


bitguru blog
Salman Ahmed
Greenhorn

Joined: Mar 18, 2008
Posts: 27
OK, I'll take a look at ImageIcon. Is it able to display images of size 1280x1024 or bigger?
Rob Spoor
Sheriff

Joined: Oct 27, 2005
Posts: 19655
    
  18

As long as your memory holds out.


SCJP 1.4 - SCJP 6 - SCWCD 5 - OCEEJBD 6
How To Ask Questions How To Answer Questions
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Displaying GIF/PNG image files in a Java Swing application
 
Similar Threads
Urgent. Please Help me!!!
Best Swing Component For Icons
Why did it have to be PNG
Where are classes for GIF, JPEG, PNG?
Image scaling/encoding