Java Forum

Ask Question   UnAnswered
Home » Forum » Java       RSS Feeds

loading an image

  Asked By: Maria    Date: Aug 06    Category: Java    Views: 785

Image img = kit.getImage("icon.gif"); // kit is a Toolkit object

if i write this on a Jframe, an icon comes at the top-left corner of
the frame.

question is , who supplies this "icon.gif" ? is it JDK? you know,
this "icon.gif" is not in mine hard-disk . i dont understand from
where it comes.

is it possible to load an image from hard drive e.g
C:\myfolder\myphoto.jpg ? how is it possible?



3 Answers Found

Answer #1    Answered By: Becky Baker     Answered On: Aug 06

You supply the icon.gif................

Answer #2    Answered By: Stacie Martin     Answered On: Aug 06

In my GYM! , I use the following code to load  icons
* loadEmoticon method comment.
public javax.swing.Icon loadEmoticon(int icon) {
return new ImageIcon(EmoticonLoader.class.getResource(icon+".gif") );

Answer #3    Answered By: Adali Fischer     Answered On: Aug 06

"You supply the icon.gif " -----what do you mean?look the code, i
have not specified the path of any icon  in my hard-disk. still it

this icon is a cup of coffe(the java emblem of sun)on the top-left
corner of a JFrame.

all i want to know, who has supplied this icon? is it inside the JDK

and second question, is it possible to load  an exisiting icon form
the hard-drive? how?

Didn't find what you were looking for? Find more on loading an image Or get search suggestion and latest updates.