Article View: borland.public.jbuilder.java.language
Article #541Re: How to load images into the code ...
From: Kevin Dean [TeamB]
Date: Thu, 30 Jun 2005 19:46
Date: Thu, 30 Jun 2005 19:46
64 lines
2785 bytes
2785 bytes
Magnus wrote:
> Hi,
>
> I have downloaded and start to test a PrinterFrameowrk set of classes
> that I found on JavaWorld.
>
> In the PFPrintPreview class the image was loaded as:
>
> firstPage.setIcon (new ImageIcon (getClass ().getResource
> ("images/FirstPage.gif")));
>
> I added the directory "images" and put the gifs there.
>
> But JBuilder could not find the images.
>
> I then tried the method that worked on earlier use:
>
> firstPage.setIcon (new ImageIcon
> (printerframework.PFPrintPreview.class.getResource
> ("FirstPage.gif")));
>
> How come that it didn't found them on the top code?
>
> Dir structure
>
> G:\jbproject\PrinterFrameWork\
> G:\jbproject\PrinterFrameWork\bak
> G:\jbproject\PrinterFrameWork\classes
> G:\jbproject\PrinterFrameWork\src
> G:\jbproject\PrinterFrameWork\src\images
> G:\jbproject\PrinterFrameWork\src\printerframework
>
> Magnus
Resources are found relative to the class that is attempting to load
them.
If this works:
printerframework.PFPrintPreview.class.getResource("FirstPage.gif")
then that means that the images are in the same directory
(printerframework) as the class.
If you want:
printerframework.PFPrintPreview.class.getResource("images/FirstPage.gif"
)
then you need to put the images in the directory below
(printerframework/images).
--
Kevin Dean [TeamB]
Dolphin Data Development Ltd.
http://www.datadevelopment.com/
NEW WHITEPAPERS
Team Development with JBuilder and Borland Enterprise Server
Securing Borland Enterprise Server
http://www.datadevelopment.com/papers/index.html
Please see Borland's newsgroup guidelines at
http://info.borland.com/newsgroups/guide.html
Technical Details
Message-ID:
<xn0e4482kj24pl002-kdean@www.teamb.com>Path:
arc1-ca.pugleaf.net!g2news1.google.com!news1.google.com!news.maxwell.syr.edu!border1.nntp.dca.giganews.com!nntp.giganews.com!pd7cy2so!shaw.ca!news-out.newsgroups.com!propagator2-sterling.newsfeeds.com!in.nntp.be!caladan.landsraad.net!newsgroups.borland.com!not-for-mailReferences:
<42c420f7@newsgroups.borland.com>Show Full Headers
Complete Article Headers
X-Google-Thread: f74b3,8cf3ca91ad1bd84d
X-Google-Attributes: gidf74b3,public
X-Google-Language: ENGLISH,ASCII-7-bit
From: "Kevin Dean [TeamB]" <NkOdSePaAnM@datadevelopment.com>
Subject: Re: How to load images into the code ...
Newsgroups: borland.public.jbuilder.java.language
References: <42c420f7@newsgroups.borland.com>
Organization: Dolphin Data Development Ltd.
User-Agent: XanaNews/1.17.5.7
X-Face: ":yn4zt^A_dn>6~{YJmu^B\'4w)e:apPM\VC=Dvf&*tASxX9|BYczkFd$xr.$vNSZ[3Uobrp]c4\+\l){!WQI.$]veP({HLd;CDYH?iN
Message-ID: <xn0e4482kj24pl002-kdean@www.teamb.com>
X-Ref: newsgroups.borland.com ~XNS:0000022F
NNTP-Posting-Host: 24.57.153.235
Date: 30 Jun 2005 12:46:55 -0700
X-Trace: newsgroups.borland.com 1120160815 24.57.153.235 (30 Jun 2005 12:46:55 -0700)
Lines: 64
X-Authenticated-User: kdean
Path: arc1-ca.pugleaf.net!g2news1.google.com!news1.google.com!news.maxwell.syr.edu!border1.nntp.dca.giganews.com!nntp.giganews.com!pd7cy2so!shaw.ca!news-out.newsgroups.com!propagator2-sterling.newsfeeds.com!in.nntp.be!caladan.landsraad.net!newsgroups.borland.com!not-for-mail