Article View: borland.public.jbuilder.java.swing
Article #9485Re: HELP: simple loading gif question
From: James Cook
Date: Mon, 27 Mar 2000 00:00
Date: Mon, 27 Mar 2000 00:00
57 lines
2591 bytes
2591 bytes
If you have a version of JBuilder that includes the New->Application
wizard...run it. Be sure to select the "create toolbar" option. This will
include the code necessary to view the images. Run the code, do you see
pictures?
jim
Stephen Legge <stephen@cryptocard.com> wrote in message
news:8bobu5$n2p4@bornews.borland.com...
>
> "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") );
>
> This doesn't work -- getClass().getResource("mypicture.gif") always
returns
> null. I'm using JBuilder 3.5 (with 1.2.2), does this only work in 1.1.x?
>
> > > 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.
>
> It doesn't appear to be working. Do you have any other suggestions?
>
> > --
> > John P. McGrath
> > <JPMcGrath@fast.net>
> > <jpm@nscs.fast.net>
>
> Stephen Legge
> Ottawa, Canada
>
>
Technical Details
Message-ID:
<38dfc972.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> <8bobu5$n2p4@bornews.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: <38dfc972.0@news.dot.state.oh.us> X-Deja-AN: 603109143 References: <8bdtn7$hr12@bornews.borland.com> <MPG.13461abddce43f35989825@forums.borland.com> <8bobu5$n2p4@bornews.borland.com> X-Trace: 27 Mar 2000 15:49:54 -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