File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Swing / AWT / SWT and the fly likes What's the most elegant approach when using icons ? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Swing / AWT / SWT
Bookmark "What Watch "What New topic

What's the most elegant approach when using icons ?

Edisandro Bessa
Ranch Hand

Joined: Jan 19, 2006
Posts: 584
Hi folks,

I would like to hear your opinions concerning the most elegant approach when using icons and other image types in my swing app.

For instance, I would like to change the system icon of my form, so I have to store such icon somewhere in my diretory structure.

I also have a JTree which according to the node type I also have to change the default folder icon shown by the API.

So I also have to have such icons stored somewhere.

What would be the best approach in these cases ?

Do you think I would simply store then in some directory and then hard code the relative directory when creating the ImageIcon object ?

Or do you think I should store them in a separate .jar file (possibly named as images.jar) and then use the getResource method
to load them ?

Or there's still another better approach I can't wonder.

I'm really interested about your opinions and would really appreciate if you could post some links to quick guides tutorials about

Edisandro Bessa.
[ September 18, 2006: Message edited by: Edisandro Bessa ]

"If someone asks you to do something you don't know how to, don't tell I don't know, tell I can learn instead." - Myself
Craig Wood
Ranch Hand

Joined: Jan 14, 2004
Posts: 1535
See the section Loading Images Using getResource on the page How to Use Icons in the Swing Tutorial. Especially the last paragraph.
Everyone seems to have their own idea of what makes sense in design. I would say to put things together in any way that makes sense to you and is easy to use.
I agree. Here's the link:
subject: What's the most elegant approach when using icons ?
It's not a secret anymore!