Re: Giving an application a window icon in a sensible way
- From: dagon@xxxxxxxxx (Mark Rafn)
- Date: Sun, 19 Nov 2006 18:06:08 -0800
Twisted <twisted0n3@xxxxxxxxx> wrote:
I want to give a Java application a window icon in a manner that is
independent of how it is installed, etc.
The trick is obtaining an Image object for myJFrame.setIconImage().
Loading it from a URL means it won't work without a working network
connection, and I need to host the image somewhere.
Not at all. A URL doesn't always mean http. It could be a file URL, or a
resource URL inside your jarfile.
Putting it in a JAR file with the app means learning a big new chunk of
API, plus it won't work when running in the development environment
rather than as a standalone executable JAR.
URL imgURL = getClass().getClassLoader().getResource("img/path");
Works if the image is in a jarfile OR a directory on the classpath.
--
Mark Rafn dagon@xxxxxxxxx <http://www.dagon.net/>
.
- Follow-Ups:
- References:
- Giving an application a window icon in a sensible way
- From: Twisted
- Giving an application a window icon in a sensible way
- Prev by Date: Re: Giving an application a window icon in a sensible way
- Next by Date: Re: faster impl of atan2 in java...
- Previous by thread: Re: Giving an application a window icon in a sensible way
- Next by thread: Re: Giving an application a window icon in a sensible way
- Index(es):