Article View: borland.public.jbuilder.java.swing
Article #9459HELP: simple loading gif question
From: Stephen Legge
Date: Thu, 23 Mar 2000 00:00
Date: Thu, 23 Mar 2000 00:00
33 lines
1355 bytes
1355 bytes
Hi,
I'm loading a gif file and placing it in a JButton like so:
ImageIcon myIcon = new ImageIcon("c:/gifs/mypicture.gif");
btnConnect.setIcon(myIcon);
and it works fine. Now I want to remove the "c:/gifs/" from the path like
so:
ImageIcon myIcon = new ImageIcon("mypicture.gif");
btnConnect.setIcon(myIcon);
But this isn't working. I tried three things:
putting the gif file in the same folder as the .java file
putting the gif file in the same folder as the .class file
adding the gif file to the JBuilder project
but nothing worked.
Can someone tell me how to get the file to load without hard-coding the full
path?
Also, when I package up my entire project as a deployable jar file, will the
gif file still be accessible?
*Any* help is greatly appreciated!
Stephen Legge
Ottawa, Canada
---
Technical Details
Message-ID:
<8bdtn7$hr12@bornews.borland.com>Path:
arc1-ca.pugleaf.net!unknown!not-for-mailShow Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 111d45,6000043aed93d9a0,start X-Google-Attributes: gid111d45,public From: "Stephen Legge" <stephen@cryptocard.com> Subject: HELP: simple loading gif question Date: 2000/03/23 Message-ID: <8bdtn7$hr12@bornews.borland.com> X-Deja-AN: 601470441 Organization: Another Netscape Collabra Server User X-MSMail-Priority: Normal X-Priority: 3 Newsgroups: borland.public.jbuilder.java.swing X-MimeOLE: Produced By Microsoft MimeOLE V5.00.2919.6700