Date: Thu, 15 Jul 1999 09:54:17 -0500 (CDT) From: Steve Price <sprice@hiwaay.net> To: Nate Williams <nate@mt.sri.com> Cc: Joachim Jaeckel <Joachim.Jaeckel@d.kamp.net>, freebsd-java@FreeBSD.ORG Subject: Re: problems loading images for buttons? Message-ID: <Pine.OSF.4.10.9907150942330.16749-100000@fly.HiWAAY.net> In-Reply-To: <199907151427.IAA02100@mt.sri.com>
index | next in thread | previous in thread | raw e-mail
On Thu, 15 Jul 1999, Nate Williams wrote:
# > I´ve a problem trying to load an image for a button.
# >
# > The description of "new ImageIcon("images/middle.gif")" says, that it
# > loads the image relative to the path where the class-file is. But if I´m
# > not in this path, the image isn´t loaded. I´m using jdk1.1.7 for FreeBSD
# > (the old static Version...). Is this a bug in the jdk or do I something
# > wrong.
#
# I'm almost positive this is 'standard behavior' of how things work.
# Where is ImageIcon documented? In my experiences, you load 'resources'
# out of the CLASSPATH, but certainly not images.
I've found that code similar to this works as expected for me.
ImageIcon(String imageName) {
Toolkit t = Toolkit.getDefaultToolkit();
URL url = ClassLoader.getSystemResource(imageName);
Image image = t.getImage(url);
return(new ImageIcon(image));
}
-steve
To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-java" in the body of the message
help
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?Pine.OSF.4.10.9907150942330.16749-100000>
