Article View: borland.public.jbuilder.java.swing
Article #9478Re: HELP: simple loading gif question
From: James Cook
Date: Mon, 27 Mar 2000 00:00
Date: Mon, 27 Mar 2000 00:00
41 lines
2025 bytes
2025 bytes
What triggers JBuilder's copying of GIF (and other resources) to the output
path. I have a directory of images, and it never gets copied...
jim
John P. McGrath <JPMcGrath@fast.net> wrote in message
news:MPG.13461abddce43f35989825@forums.borland.com...
> On Thu, 23 Mar 2000 15:23:00 -0500, Stephen Legge wrote:
>
> > 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);
>
> Try:
> ImageIcon myIcon = new ImageIcon(
> getClass().getResource("mypicture.gif") );
>
> > 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.
>
> Place the image file in the same folder as the source file for the Java
> class that contains the above code, and add it to your project. JBuilder
> will automatically copy it to the folder that contains the .class file,
> which is where it needs to be.
>
> --
> John P. McGrath
> <JPMcGrath@fast.net>
> <jpm@nscs.fast.net>
>
Technical Details
Message-ID:
<38df7850.0@news.dot.state.oh.us>Path:
arc1-ca.pugleaf.net!unknown!not-for-mailReferences:
<8bdtn7$hr12@bornews.borland.com> <MPG.13461abddce43f35989825@forums.borland.com>Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 111d45,6000043aed93d9a0 X-Google-Attributes: gid111d45,public From: "James Cook" <jimcook.spaminator@remove.for.spam.iname.com> Subject: Re: HELP: simple loading gif question Date: 2000/03/27 Message-ID: <38df7850.0@news.dot.state.oh.us> X-Deja-AN: 602973182 References: <8bdtn7$hr12@bornews.borland.com> <MPG.13461abddce43f35989825@forums.borland.com> X-Trace: 27 Mar 2000 10:03:44 -0500, dotfw001-dmz.dot.state.oh.us X-MSMail-Priority: Normal X-Priority: 3 Newsgroups: borland.public.jbuilder.java.swing X-MimeOLE: Produced By Microsoft MimeOLE V5.00.2314.1300