Article View: borland.public.jbuilder.java.swing
Article #9079Re: path and filename structures
From: John P. McGrath
Date: Tue, 23 May 2000 00:00
Date: Tue, 23 May 2000 00:00
39 lines
1624 bytes
1624 bytes
Try this:
URL url = getClass().getResource( "images/explode.gif" ) );
Icon icon = new ImageIcon( url );
--
John P. McGrath
<JPMcGrath@fast.net>
<jpm@nscs.fast.net>
On Mon, 22 May 2000 00:45:20 -0300, Alan Shiers wrote:
> Hi there:
> I'm trying to understand how to designate the path to a particular
> file when making use of the ImageIcon(String filename) class. In the
> help files it explains that the filename arguement should be something
> like: "images/explode.gif"
>
> My directory stucture is like this:
>
> network
> |__ jbsc
> |__images
>
> My class files are in jbsc. I place a copy of explode.gif in all three
> directories.
> Then I tried ImageIcon("images/explode.gif"). I expected it to find the
> file in the images directory but it didn't. So I tried just
> ImageIcon("explode.gif") thinking it will at least find the file in jbsc
> (the same directory as the class files). Nope, it didn't. So I tried
> ImageIcon("network/explode.gif"). This time it found it!
>
> The thing is, I want it to load from the images directory. So how do I
> tell it that?
>
> Alan
>
>
Technical Details
Message-ID:
<MPG.1393d7aa1c61f59f98993f@forums.borland.com>Path:
arc1-ca.pugleaf.net!unknown!not-for-mailReferences:
<3928AD50.FC6E635@istar.ca>Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 111d45,927b2d377af0df42,start X-Google-Attributes: gid111d45,public From: John P. McGrath <JPMcGrath@fast.net> Subject: Re: path and filename structures Date: 2000/05/23 Message-ID: <MPG.1393d7aa1c61f59f98993f@forums.borland.com> X-Deja-AN: 626141397 References: <3928AD50.FC6E635@istar.ca> Organization: Another Netscape Collabra Server User Newsgroups: borland.public.jbuilder.java.swing