com.resilientedge.jockey.util.tooltray
Class DesktopIndicator

java.lang.Object
  |
  +--com.resilientedge.jockey.util.tooltray.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.


Field Summary
static int OPTION_EXIT
           
static int OPTION_USER1
           
static int OPTION_USER2
           
static int OPTION_USER3
           
static int OPTION_USER4
           
static int OPTION_USER5
           
static int OPTION_USER6
           
static int OPTION_USER7
           
static int OPTION_USER8
           
static int OPTION_USER9
           
 
Constructor Summary
DesktopIndicator()
          Creates a desktop indicator, initially hidden.
DesktopIndicator(int image, java.lang.String tooltip)
          Creates a desktop indicator, initially hidden.
 
Method Summary
 void addDesktopIndicatorListener(DesktopIndicatorListener listener)
          Adds a listener for clicks.
 int addOption(java.lang.String option)
          Add an option to the menu of choices available from the desktop indicator.
protected  void finalize()
          Makes sure that the desktop indicator is hidden.
 void fireClicked()
          Notifies all listeners that the desktop indicator was clicked.
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.
static boolean initialize(boolean useCrossPlat)
          Loads the JNI library, if available.
static int loadImage(java.lang.String filename)
          Loads an image file to memory.
static int loadImageFromResource(int inResourceNum)
          Loads an image file to memory.
 void removeDesktopIndicatorListener(DesktopIndicatorListener listener)
          Removes a listener for clicks.
 void sendMessage(int option)
          Notifies all listeners that the desktop indicator was clicked.
 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
 

Field Detail

OPTION_EXIT

public static final int OPTION_EXIT

OPTION_USER1

public static final int OPTION_USER1

OPTION_USER2

public static final int OPTION_USER2

OPTION_USER3

public static final int OPTION_USER3

OPTION_USER4

public static final int OPTION_USER4

OPTION_USER5

public static final int OPTION_USER5

OPTION_USER6

public static final int OPTION_USER6

OPTION_USER7

public static final int OPTION_USER7

OPTION_USER8

public static final int OPTION_USER8

OPTION_USER9

public static final int OPTION_USER9
Constructor Detail

DesktopIndicator

public DesktopIndicator()
Creates a desktop indicator, initially hidden.

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

addOption

public int addOption(java.lang.String option)
Add an option to the menu of choices available from the desktop indicator.
Parameters:
string - to describe option
Returns:
int value corresponding to option; it is this value that will be passed as a parameter to DesktopIndicatorListener.onMessage().

addDesktopIndicatorListener

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

fireClicked

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

sendMessage

public void sendMessage(int option)
Notifies all listeners that the desktop indicator was clicked.

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.

hide

public void hide()
Hides the desktop indicator.

removeDesktopIndicatorListener

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

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.

initialize

public static boolean initialize()
Loads the JNI library, if available. If not available, tries to load a cross-platform version of a desktop indicator. Same as initialize(true).

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

initialize

public static boolean initialize(boolean useCrossPlat)
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.

loadImageFromResource

public static int loadImageFromResource(int inResourceNum)
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.

finalize

protected void finalize()
Makes sure that the desktop indicator is hidden.
Overrides:
finalize in class java.lang.Object


Copyright © 2001 Resilient Edge, Inc. All Rights Reserved.