Overview | Package | Class | Use | Tree | Deprecated | Index | Help
| JDIC API V2006 Release 0308
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## org.jdesktop.jdic.tray
Class TrayIcon

    java.lang.Object
      org.jdesktop.jdic.tray.TrayIcon

    public class TrayIcon

extends java.lang.Object

The `TrayIcon` class represents a tray Icon that can be added to a System tray. A TrayIcon can have a caption (text), an Icon and a menu associated with it. In addition a TrayIcon can also have a tooltip associated that is displayed when the mouse hovers over the TrayIcon.

TrayIcons will display the specified Menu when a right mouse click is performed on the TrayIcon. Left button clicking will trigger ActionEvents.

Field Summary
`static int` | `ERROR_MESSAGE_TYPE` Used for error messages.
`static int` | `INFO_MESSAGE_TYPE` Used for information messages.
`static int` | `NONE_MESSAGE_TYPE` No icon is used.
`static int` | `WARNING_MESSAGE_TYPE` Used for warning messages.

Constructor Summary
`TrayIcon(javax.swing.Icon i)` TrayIcon constructor - creates a TrayIcon with the specified Icon
`TrayIcon(javax.swing.Icon icon, java.lang.String caption)` TrayIcon constructor - creates a TrayIcon with the specified Icon and the specified caption.
`TrayIcon(javax.swing.Icon icon, java.lang.String tooltip, javax.swing.JPopupMenu popup)` TrayIcon constructor - creates a TrayIcon with the specified Icon the specified caption and Popup menu.

Method Summary
`void` | `addActionListener(java.awt.event.ActionListener listener)` Adds the specified ActionListener to the list of ActionListeners for this component.
`void` | `addBalloonActionListener(java.awt.event.ActionListener listener)` Adds the specified ActionListener to the list of ActionListeners for this trayicon's balloon message.
`void` | `displayMessage(java.lang.String caption, java.lang.String text, int type)` Displays a popup message near the tray icon.
`java.awt.Point` | `getLocationOnScreen()` Gets the location on screen for this TrayIcon
`void` | `removeActionListener(java.awt.event.ActionListener listener)` Removes the specified ActionListener from the list of ActionListeners for this component.
`void` | `removeBalloonActionListener(java.awt.event.ActionListener listener)` Removes the specified ActionListener from the list of ActionListeners for this trayicon's balloon message.
`void` | `setCaption(java.lang.String caption)` Sets the caption for this TrayIcon.
`void` | `setIcon(javax.swing.Icon icon)` Sets the icon for this TrayIcon.
`void` | `setIconAutoSize(boolean autosize)` Sets the auto-size property.
`void` | `setPopupMenu(javax.swing.JPopupMenu popup)` Sets the PopupMenu for this TrayIcon.
`void` | `setToolTip(java.lang.String tooltip)` Sets the ToolTip string for this TrayIcon.

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Field Detail

### INFO_MESSAGE_TYPE

    public static final int INFO_MESSAGE_TYPE

  Used for information messages.

  See Also:
    Constant Field Values

### ERROR_MESSAGE_TYPE

    public static final int ERROR_MESSAGE_TYPE

  Used for error messages.

  See Also:
    Constant Field Values

### WARNING_MESSAGE_TYPE

    public static final int WARNING_MESSAGE_TYPE

  Used for warning messages.

  See Also:
    Constant Field Values

### NONE_MESSAGE_TYPE

    public static final int NONE_MESSAGE_TYPE

  No icon is used.

  See Also:
    Constant Field Values

Constructor Detail

### TrayIcon

    public TrayIcon(javax.swing.Icon i)

  TrayIcon constructor - creates a TrayIcon with the specified Icon

### TrayIcon

    public TrayIcon(javax.swing.Icon icon,
                    java.lang.String caption)

  TrayIcon constructor - creates a TrayIcon with the specified Icon and the specified caption.

  Parameters:
    `icon` - Icon
    `caption` - caption to use

### TrayIcon

    public TrayIcon(javax.swing.Icon icon,
                    java.lang.String tooltip,
                    javax.swing.JPopupMenu popup)

  TrayIcon constructor - creates a TrayIcon with the specified Icon the specified caption and Popup menu.

  Parameters:
    `icon` - Icon
    `tooltip` - tooltip to use
    `popup` - popupMenu to use

Method Detail

### setIcon

    public void setIcon(javax.swing.Icon icon)

  Sets the icon for this TrayIcon.

  Parameters:
    `icon` - icon to use

### setPopupMenu

    public void setPopupMenu(javax.swing.JPopupMenu popup)

  Sets the PopupMenu for this TrayIcon.

  Parameters:
    `popup` - Popup

### setToolTip

    public void setToolTip(java.lang.String tooltip)

  Sets the ToolTip string for this TrayIcon. For windows,it can have a maximum of 64 characters including the terminating NULL.

  Parameters:
    `tooltip` -

### addActionListener

    public void addActionListener(java.awt.event.ActionListener listener)

  Adds the specified ActionListener to the list of ActionListeners for this component.

  Parameters:
    `listener` -

### removeActionListener

    public void removeActionListener(java.awt.event.ActionListener listener)

  Removes the specified ActionListener from the list of ActionListeners for this component.

  Parameters:
    `listener` -

### setCaption

    public void setCaption(java.lang.String caption)

  Sets the caption for this TrayIcon.

  Parameters:
    `caption` -

### setIconAutoSize

    public void setIconAutoSize(boolean autosize)

  Sets the auto-size property. Auto-size determines whether the tray icon is automatically sized to fit the actual tray size.

### getLocationOnScreen

    public java.awt.Point getLocationOnScreen()

  Gets the location on screen for this TrayIcon

  Returns:
    Point

### displayMessage

    public void displayMessage(java.lang.String caption,
                               java.lang.String text,
                               int type)
                        throws java.lang.NullPointerException

  Displays a popup message near the tray icon. The message will disappear after a timeout or if user clicks on it.

  Either the caption or the text may be null, but an NullPointerException is thrown if both are null.

  Note: Some platforms may not support showing a message.

  Parameters:
    `caption` - the caption displayed above the text, usually in bold; may be null
    `text` - the text displayed for the particular message; may be null
    `type` - the type of message to be displayed: `INFO_MESSAGE_TYPE`, `ERROR_MESSAGE_TYPE`, `WARNING_MESSAGE_TYPE`, `NONE_MESSAGE_TYPE`
  Throws:
    `java.lang.NullPointerException` - If both caption and text are null

### addBalloonActionListener

    public void addBalloonActionListener(java.awt.event.ActionListener listener)

  Adds the specified ActionListener to the list of ActionListeners for this trayicon's balloon message.

  Parameters:
    `listener` -

### removeBalloonActionListener

    public void removeBalloonActionListener(java.awt.event.ActionListener listener)

  Removes the specified ActionListener from the list of ActionListeners for this trayicon's balloon message.

  Parameters:
    `listener` -

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
| JDIC API V2006 Release 0308
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

For more information and documentation on JDIC, see JDIC website.

That documentation contains more detailed, developer-targeted descriptions, with conceptual overviews, working code examples, license terms and bug report information.

Copyright (c) 2004 Sun Microsystems, Inc. All rights reserved. Use is subject to license terms.