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




Twisted wrote:
Mark Rafn wrote:
Wouldn't it be MUCH easier to put gif/jpg/png files directly into the jar,
then let the classloader find them using getResource or getResourceAsStream?

First of all, I don't *have* a jar, at least not yet.

Second of all, this is the kind of thing that should really just work
without being able to bomb with IOExceptions and suchlike, in my
opinion. Retrieving even the most basic stuff from a bunch of external
files adds unnecessary points of failure, and gobs of extra recovery
code to check for and cope with anything that goes wrong. This way, it
Just Works(tm). :)

"It Just Works(TM)" is considered a very bad approach to software
design. Doing things that "Just Work" versus doing things that "Work
Right", tends to save a minute now and cost a week later. What happens
when you have three icons? 10? What happens when you rebrand those 10
icons? Having them as actual image files rather than converting them.
Ouch.

BTW, if you REALLY wanted to go that route, you could do a byte dump of
the original (png/jpeg/gif) image, and use imageio and a
ByteArrayInputStream (there is such a thing, right?). Releasing you
from using the apperantly buggy XImageWhatchamawhosit. Although, I
wouldn't recommend either approach.

.



Relevant Pages

  • Re: configuration required to load icons from disk
    ... getResource in jar file is case-sensitive, ... outside of jar file is case-insenstivie. ... public static void mainthrows AWTException, ... Make/Get an image file, name it case sensitively,GetResourcePic.gif ...
    (comp.lang.java.gui)
  • Re: URI is not hierarchical
    ... >> stream of data in the jar file. ... >> with the File object because it's not a real file. ... >> getResource() and then read the data from the resulting InputStream. ... Then create an output stream for writing the new file (which ...
    (comp.lang.java.programmer)
  • Re: Bilder und Textdateien aus Jar laden
    ... Wenn alles auf Platte ist, funktioniert das auch, aber im jar geht es ... Die Klasse MyMain kann nun die drei Bilder alle mit ähnlichen Aufrufen ... Programm nicht in ein Jar gepackt hast. ... Experimentiere einfach ein wenig mit getResource() und dem ClassPath, ...
    (de.comp.lang.java)
  • Re: how to get application path? Is that my method in getting path wrong?
    ... > class(without jar), that code can get correct path and the file. ... > at center it come out something like jar file(it act like 1 level ... When working with getResource() you aren't really working with regular ... If you want to read and write to a local disk, ...
    (comp.lang.java.programmer)
  • Re: imageicon on jbutton
    ... Look at getResource and how it composes an URL to find the image in ... the jar. ... Canadian Mind Products, Roedy Green. ...
    (comp.lang.java.gui)