🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: borland.public.jbuilder.java.api
Article #320

Re: Problems with loading & displaying a picture

#320
From: Andreas Koch
Date: Mon, 02 Feb 2004 21:29
94 lines
3334 bytes
Thanks a lot for your reply.

>   ^jbuilder furbacher images directories

Thanks, had a quick look on it.

> They must be on the classpath.

Forgive my stupidy. I have about 5 hours of java
experience. What exactly is the "classpath"?

/MyProject/classes ?


> For instance, if you have the package and class
> 
>   org.myorg.views.MyPanel

If have the project test2.jpx which has a class
named ClockAnalogBuf.java.
No idea what a package is :-)

> and MyPanel uses some images (e.g., image1.png
> and image2.png), 

0196.png etc in my case.

> the best packaging/structuring
> of these images is
> 
>   // given a root folder for your project, MyProject
> 
>   .../MyProject
>        /bak
>        /doc
>        /classes
>        /src
>          /org
>            /myorg
>               /views
>                 - MyPanel.java
>                 /images
>                   - image1.png
>                   - image2.png

Ok, i put my images in two (identical) images
subfolders:

/test2
   /bak
   /classes
     /package cache
       *test2.dep2
     /test2
       *ClockAnalogBuf.class
       ...
       /images
         *0196.png
         ...
   /doc
   /src
     /test2
       *ClockAnalogBuf.java
       ...
       /images
         *0196.png
         ...

> Given this packaging/directory structure, you
> would get your Image using
> 
>   URL url = MyPanel.class.getResource("images/image1.png");
>   // with the URL, you can now get your ImageIcon.

Doesn't work:
         TileGfx[0] = toolkit.getImage("/images/0196.png");
Doesn't work:
         TileGfx[0] = toolkit.getImage("images/0196.png");
Works:
         TileGfx[0] = 
toolkit.getImage("c:/projects/test2/classes/test2/images/0196.png");

Is there any difference in the file name handling of
getResource vs. toolkit.getImage ?

> Also, it might be a good idea to drill down into
> the code for ImageIcon

Quite lengthy. I'll take a look at it tomorrow :-D


-- 
                                   Andreas
He screamed: THIS IS SIG!
Technical Details
Message-ID: <401ec0a4$1@newsgroups.borland.com>
Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!news2.google.com!news.maxwell.syr.edu!newshosting.com!news-xfer1.atl.newshosting.com!diablo.voicenet.com!217.196.175.6.MISMATCH!centaur.lucky.net!carrier.kiev.ua!info.elvisti.kiev.ua!news.donbass.net!newsgroups.borland.com!not-for-mail
References: <401d06eb$1@newsgroups.borland.com> <pan.2004.02.02.08.34.02.603265@yahoo.de> <401e9d7b@newsgroups.borland.com> <401eb6e1@newsgroups.borland.com>

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: 1089d0,cc9d3c5ba1462852
X-Google-Attributes: gid1089d0,public
X-Google-ArrivalTime: 2004-02-02 13:38:57 PST
Date: Mon, 02 Feb 2004 22:29:57 +0100
From: Andreas Koch <nospam@kochandreas.com>
User-Agent: Mozilla/5.0 (Windows; U; Win98; en-US; rv:1.6) Gecko/20040113
X-Accept-Language: en-us, en
MIME-Version: 1.0
Newsgroups: borland.public.jbuilder.java.api
Subject: Re: Problems with loading & displaying a picture
References: <401d06eb$1@newsgroups.borland.com> <pan.2004.02.02.08.34.02.603265@yahoo.de> <401e9d7b@newsgroups.borland.com> <401eb6e1@newsgroups.borland.com>
In-Reply-To: <401eb6e1@newsgroups.borland.com>
Content-Type: text/plain; charset=us-ascii; format=flowed
Content-Transfer-Encoding: 7bit
NNTP-Posting-Host: 217.255.119.62
Message-ID: <401ec0a4$1@newsgroups.borland.com>
X-Trace: newsgroups.borland.com 1075757220 217.255.119.62 (2 Feb 2004 13:27:00 -0800)
Lines: 94
Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!news2.google.com!news.maxwell.syr.edu!newshosting.com!news-xfer1.atl.newshosting.com!diablo.voicenet.com!217.196.175.6.MISMATCH!centaur.lucky.net!carrier.kiev.ua!info.elvisti.kiev.ua!news.donbass.net!newsgroups.borland.com!not-for-mail