IconLocator
Description
IconLocator is a simple Java library to handle loading of system icons (there is also the IconService project of JDIC, but it makes use of external dynamic libraries (.dll and .so) as it uses the JNI).
Limitations - Supported platforms
The main target is to locate the desired icons by scanning the filesystem (so it cannot locate Windows icons - only desktop environments that conform to the Freedesktop Icon Theme Specification are supported, e.g. Gnome, KDE, XFCE).
Currently only PNG files are supported.
How to use it
In order to load icons, you have to make an instance of IconManager:
IconManager iconManager = new IconManager(null); //No FallbackIconLoader is used here
Instead of null, you can pass an instance of a class implementing the FallBackIconLoader interface.
A FallbackIconLoader is used in case no suitable system icon could be found.
After creating the IconManager instance you can get an ImageIcon representing the desired icon with a call to the IconManager’s getIcon() method, specifying the name and size of the desired icon:
iconManager.getIcon(”document-new”, 24);
and on my system the result would be:
![]()
(On platforms that are not supported the supplied FallbackIconLoader will always be used instead of searching for icons.)
Download
- Binaries (JavaDoc included): IconLocator.zip
- Source (Netbeans 6.5 project) : IconLocator-src.zip
Licence
You are free to use the library and modify the code as you wish, as long as you refer to me (Georgios Migdos) as the original author.
Leave a Reply
You must be logged in to post a comment.