Article View: borland.public.jbuilder.java.api
Article #325Re: Problems with loading & displaying a picture
From: Andreas Koch
Date: Tue, 03 Feb 2004 20:08
Date: Tue, 03 Feb 2004 20:08
30 lines
2170 bytes
2170 bytes
marcin brzoza wrote:
> Errata:
> WRONG: ClassLoader loader = this.getClassLoader();
> OK: ClassLoader loader = this.getClass().getClassLoader();
> sorry :)
Ah, perfect. And with
TileGfx[0] = new
ImageIcon(loader.getResource("test2/images/0196.png")).getImage();
i can even put it into my Image.
>>Is there any difference in the file name handling of getResource vs.
>>toolkit.getImage ?
>
> Yes. If you use toolkit, you must use Mediatracker. With
> ClassLoader.getResource() you can read resources (like text files or
> images) from classpath or jar files.
Thanks a lot! The Classloader method works now, even from a JAR !
I think i have to meditate a bit about what the Mediatracker
does but waiting for the picture to load, and why the toolkit
seems to use paths not relative to the classpath ;-)
--
Andreas
He screamed: THIS IS SIG!
Technical Details
Message-ID:
<401ffef9@newsgroups.borland.com>Path:
arc1-ca.pugleaf.net!archiver1.google.com!news2.google.com!news.maxwell.syr.edu!newsfeed.icl.net!newsfeed.fjserv.net!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mailReferences:
<401d06eb$1@newsgroups.borland.com> <pan.2004.02.02.08.34.02.603265@yahoo.de> <401e9d7b@newsgroups.borland.com> <401eb6e1@newsgroups.borland.com> <401ec0a4$1@newsgroups.borland.com> <pan.2004.02.03.08.00.17.788217@yahoo.de>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-03 12:10:28 PST Date: Tue, 03 Feb 2004 21:08:32 +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> <401ec0a4$1@newsgroups.borland.com> <pan.2004.02.03.08.00.17.788217@yahoo.de> In-Reply-To: <pan.2004.02.03.08.00.17.788217@yahoo.de> Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit NNTP-Posting-Host: 217.226.113.126 Message-ID: <401ffef9@newsgroups.borland.com> X-Trace: newsgroups.borland.com 1075838713 217.226.113.126 (3 Feb 2004 12:05:13 -0800) Lines: 30 Path: arc1-ca.pugleaf.net!archiver1.google.com!news2.google.com!news.maxwell.syr.edu!newsfeed.icl.net!newsfeed.fjserv.net!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail