Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / General / January 2008

Tip: Looking for answers? Try searching our database.

Loading an Image

Thread view: 
mohed.haidar@gmail.com - 02 Jan 2008 10:53 GMT
Hello guys. I have been trying hard to load an Image but with no luck.
Basically I want an application that can take an Image (jpeg) from a
specified location on my disk and show it. I get confused with all the
canvas, paint, render ,update stuff that makes the task seam very
complicated when i feel that its not so. Any ideas ?? And also if you
guys would have a problem like mine how would you go about finding a
solution ?? Thank you for your time.
Owen Jacobson - 02 Jan 2008 11:09 GMT
On Jan 2, 2:53 am, mohed.hai...@gmail.com wrote:
> Hello guys. I have been trying hard to load an Image but with no luck.
> Basically I want an application that can take an Image (jpeg) from a
[quoted text clipped - 3 lines]
> guys would have a problem like mine how would you go about finding a
> solution ?? Thank you for your time.

1. Use ImageIO to load the file into an Image object:
 <http://java.sun.com/docs/books/tutorial/2d/images/loadimage.html>

2. Use the Image object to create an ImageIcon object.

3. Place the ImageIcon widget in a JLabel and add the label to your
window.

Check the javadocs on ImageIO, Image, ImageIcon, and JLabel for a
fairly thorough explanation of how all this fits together.  The
tutorial link I gave you proposes a second way to do it, which is more
useful if you need to transform the image (scale, rotate, recolour,
alpha-blend, et cetera) before drawing it.

-o
Knute Johnson - 02 Jan 2008 18:40 GMT
> On Jan 2, 2:53 am, mohed.hai...@gmail.com wrote:
>> Hello guys. I have been trying hard to load an Image but with no luck.
[quoted text clipped - 20 lines]
>
> -o

Also look here for some example code on how to load and display and image.

http://rabbitbrush.frazmtn.com

And I would use the ImageIO method not the others.

Signature

Knute Johnson
email s/nospam/knute/

Chase Preuninger - 02 Jan 2008 22:59 GMT
In swing all the stuff u nead is in the imageIO package

javax.imageio.ImageIO.load(...);


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2009 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.