edu.ou.kmi.buddyspace.gui.systemtray
Class DesktopIndicator

java.lang.Object
  |
  +--edu.ou.kmi.buddyspace.gui.systemtray.DesktopIndicator

public class DesktopIndicator
extends java.lang.Object

A JNI wrapper for desktop indicators (also called tray icons and taskbar icons).

The actual implementation is platform specific. Currently only Win32 is supported. For unsupported platforms, the desktop indicator doesn't do anything, and is otherwise harmless. Likewise, some platforms may not support the tooltip feature.

IMPORTANT!

Relying on this feature will make your applet or application platform- dependant. If possible, treat is as an "added benefit", not a required feature.


Constructor Summary
DesktopIndicator(int image, java.lang.String tooltip)
          Creates a desktop indicator, initially hidden.
 
Method Summary
 void addDesktopIndicatorListener(DesktopIndicatorListener listener)
          Adds a listener for clicks.
protected  void finalize()
          Makes sure that the desktop indicator is hidden.
 void fireClicked()
          Notifies all listeners that the desktop indicator was clicked.
 void fireExit()
          Notifies all listeners that exit was clicked.
 void firePresenceChange(java.lang.String presenceStr)
          Notifies all listeners that presence was changed.
static void freeImage(int image)
          Frees memory used by a image previously loaded with loadImage.
 void hide()
          Hides the desktop indicator.
static boolean initialize()
          Loads the JNI library, if available.
 boolean isScreenSaverActive()
          Returns if a screen server is running.
static int loadImage(java.lang.String filename)
          Loads an image file to memory.
 void removeDesktopIndicatorListener(DesktopIndicatorListener listener)
          Removes a listener for clicks.
 void show()
          Enables the desktop indicator.
 void update(int image, java.lang.String tooltip)
          Updates the desktop indicator with an image and tooltip.
 
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DesktopIndicator

public DesktopIndicator(int image,
                        java.lang.String tooltip)
Creates a desktop indicator, initially hidden.

The image handle is the return value of a previous call to loadImage.

Method Detail

initialize

public static boolean initialize()
Loads the JNI library, if available.

Must be called before images are loaded and instances are created.


loadImage

public static int loadImage(java.lang.String filename)
Loads an image file to memory.

The image is loaded from the filename parameter, while the tooltip is supplied in the tooltip parameter. The image file must be in a format recognized by the native platform (for example, a .ico file for Win32).

A return value of -1 indicates failure. Otherwise, it is the handle of the image to be used for desktop indicators.


freeImage

public static void freeImage(int image)
Frees memory used by a image previously loaded with loadImage.

The memory is freed in any case when the VM is closed.


show

public void show()
Enables the desktop indicator.

If the indicator is already active, it is "refreshed" with the filename and tooltip.


update

public void update(int image,
                   java.lang.String tooltip)
Updates the desktop indicator with an image and tooltip.


hide

public void hide()
Hides the desktop indicator.


isScreenSaverActive

public boolean isScreenSaverActive()
Returns if a screen server is running.


fireClicked

public void fireClicked()
Notifies all listeners that the desktop indicator was clicked.


firePresenceChange

public void firePresenceChange(java.lang.String presenceStr)
Notifies all listeners that presence was changed.


fireExit

public void fireExit()
Notifies all listeners that exit was clicked.


addDesktopIndicatorListener

public void addDesktopIndicatorListener(DesktopIndicatorListener listener)
Adds a listener for clicks.


removeDesktopIndicatorListener

public void removeDesktopIndicatorListener(DesktopIndicatorListener listener)
Removes a listener for clicks.


finalize

protected void finalize()
Makes sure that the desktop indicator is hidden.

Overrides:
finalize in class java.lang.Object