Re: Giving an application a window icon in a sensible way



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/>
.