Article View: borland.public.jbuilder.java.language
Article #7599Re: How-to keep images in resources(?) in a java application for use in e.g. menus?
From: Ken Warner
Date: Tue, 12 Jun 2001 17:21
Date: Tue, 12 Jun 2001 17:21
37 lines
2530 bytes
2530 bytes
Ha-ha -- figured out how to make JBuilder add code like:
playButton.setIcon(new ImageIcon(JSound.class.getResource("Play24.gif")));
The gif file has to be in the package folder --
That is, if you have only the default package, i.e.. no package, then the gif file has
to be in the same folder as the source for the app/applet. It can't be anywhere else.
If you put the gif file in an other place or if you want more that one app/applet to
use the same gif -- too bad. It has to be in the package folder. So if the class that
uses the gif is in package foo.bar then the gif has to be in bar.
When you rebuild your project, the gif file will be automagically copied to the output
folder where the classes are. So you are guaranteed to end up with at least two copies of the
gif file -- or more if other apps/applets are using the same gif.
When I told "TeamB" that this was a stupid way to do things, I was rebuked and reprimanded with
permanent black marks placed on my record...
Thomas Schulz wrote:
> E.g. for this:
>
> setIconImage(Toolkit.getDefaultToolkit().createImage(FrameEditor.class.getRe
> source("[Back16.gif]")));
>
> I tryed to inlclude a file called Back16.gif in my project.. I guess that
> doesn't do the trick... I suspect I'll need to make a Jar file or something?
> Well.. But I would like to see it design time too if possible?
> What to do, where to read, anyone knows (tryed google search on resources
> and java)?
>
> Regards
> Thomas Schulz
--
Ken Warner
Technical Details
Message-ID:
<3B264F89.7C4CCA86@cts.com>Path:
arc1-ca.pugleaf.net!archiver1.google.com!newsfeed.google.com!sn-xit-02!supernews.com!newsfeed.direct.ca!look.ca!news.maxwell.syr.edu!newsfeed00.sul.t-online.de!t-online.de!news-lei1.dfn.de!newsfeed.freenet.de!news1.dtag.de!news.stgl.sel.alcatel.de!news.stgl.sel.alcatel.de!dnewsReferences:
<3b1a26d5$1_1@dnews>Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: f74b3,9cd5cec6235717ef X-Google-Attributes: gidf74b3,public X-Google-ArrivalTime: 2001-06-12 10:31:43 PST Message-ID: <3B264F89.7C4CCA86@cts.com> Date: Tue, 12 Jun 2001 10:21:13 -0700 From: Ken Warner <kwarner@cts.com> X-Mailer: Mozilla 4.73 [en] (WinNT; U) X-Accept-Language: en MIME-Version: 1.0 Newsgroups: borland.public.jbuilder.java.language Subject: Re: How-to keep images in resources(?) in a java application for use in e.g. menus? References: <3b1a26d5$1_1@dnews> Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit NNTP-Posting-Host: 216.120.8.37 X-Trace: dnews 992366500 216.120.8.37 (12 Jun 2001 10:21:40 -0700) Lines: 39 Path: arc1-ca.pugleaf.net!archiver1.google.com!newsfeed.google.com!sn-xit-02!supernews.com!newsfeed.direct.ca!look.ca!news.maxwell.syr.edu!newsfeed00.sul.t-online.de!t-online.de!news-lei1.dfn.de!newsfeed.freenet.de!news1.dtag.de!news.stgl.sel.alcatel.de!news.stgl.sel.alcatel.de!dnews