Skip to Main Content

New to Java

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

importing gif file to ImageIcon

807600Aug 1 2007 — edited Aug 1 2007
Hi,

I am trying to use a gif file that I have included in my project (using Windows XP). I am trying to stick the image from the gif file into a ImageIcon variable, and sticking the variable into a label. Here is the code that I am using to have the program access the gif file:

private ImageIcon redX = new ImageIcon( " \\JAVA programs\\Week 8\\lab8_1a\\redshd.gif " );

I have a classPath setup in my environment variables/system variables as follows:

.;C:\Documents and Settings\Jim Roth\My Documents\Visual Studio Projects\Programs

and the path to the gif file is as follows:

C:\Documents and Settings\Jim Roth\My Documents\Visual Studio Projects\Programs\JAVA programs\Week 8\Lab8_1A\redshd.gif

When I run the program, the screen comes up empty. I am using a basic frame, with a GridLayout. When I change the input into the label to a string, it shows up on the label when the program runs.

In debug mode, I am not quite sure of what the values apply to, but oneonf them shows up as 'null'.

I think my problem lies with the program just not finding the gif.file. Any suggestions?

Thanks a lot!

Jimbo
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Aug 29 2007
Added on Aug 1 2007
4 comments
181 views