Magazin

I've created a lot of small helpers as also complete swing components for developing gui's with java in the past. This is the first episode of the Toolbox series I want to start here. I'll present you classes out of my GUILibrary in the future. So say Hello to the GUIImageManager.

What is it?

If you create gui's today, you usually use images to create a better experience for the user. As you may have noticed, there is a flickering when you display an image on the gui (of course not if you use the mediatracker... Everytime).
Also it isn't very satisfying to reload an image everitme from its file.

Here takes the GUIImageManager place. He's a cache for all your gui images.
Just tell the manager which image you want and he will deliver it to you and takes care about caching in the background. If you need the image again, the manager loads it directly from the cache.

How to use?

GUIImageManager is implemented as a singleton. To make the use of the manager as easy as possible, you have to initialize the manager on the application start to tell him where your gui images are placed (I usually use a package like /net/msites/xy/gui/res/).

GUIImageManager.loadImageManager("/net/msites/myapp/gui/res/");

After this, you're ready to use the manager. Just use following code to get an image:

BufferedImage image = GUIImageManager.getInstance().getImage("myimage.png");

Have a look into the sourcecode for more information about the available getImage() methods.

License & Download

It is free for use, but please mention me in your credits if you use the class. Thanks :-)
If you have any additions or feedback, please feel free to leave a comment.

Interaktiv

Den ersten Kommentar schreiben






Ihre E-Mail-Adresse wird nur zur internen Identifikation gespeichert und wird absolut vertraulich behandelt sowie auf keine Weise zu Werbezwecken missbraucht!
Auch ich mag keinen Spam :-)

Soziale Netze & Abos

Ihnen gefällt "Toolbox: GUIImageManager"?

Dann teilen Sie diese Seite mit Ihren Freunden und Bekannten via Delicious, Facebook, Twitter und Digg.

Oder Sie abonnieren einfach den kostenlosen RSS Feed und bleiben immer auf dem aktuellsten Stand.