com.jniwrapper.win32.shell
Class TrayIcon

java.lang.Object
  extended byjava.awt.Component
      extended bycom.jniwrapper.win32.shell.TrayIcon
All Implemented Interfaces:
java.awt.image.ImageObserver, java.awt.MenuContainer, java.io.Serializable

public class TrayIcon
extends java.awt.Component

TrayIcon class enables to add/modify a tray icon and its properties such as hint, icon, tooltip, callout.

You can register TrayIcon listeners for receiving mouse events (WM_MOUSEMOVE, WM_LBUTTONDOWN etc.)

See Also:
Serialized Form

Nested Class Summary
 
Nested classes inherited from class java.awt.Component
java.awt.Component.AccessibleAWTComponent, java.awt.Component.BltBufferStrategy, java.awt.Component.FlipBufferStrategy
 
Field Summary
static int WM_RESTORE_TRAY
           
static int WM_TRAY
           
 
Fields inherited from class java.awt.Component
BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT
 
Fields inherited from interface java.awt.image.ImageObserver
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH
 
Constructor Summary
TrayIcon()
           
TrayIcon(Icon icon)
          Creates an instance of TrayIcon with a specified icon.
 
Method Summary
 void addTrayListener(BalloonListener listener)
          Adds a balloon events listener for the specified tray icon.
 void addTrayListener(java.awt.event.MouseListener listener)
          Adds a standard mouse listener for the tray icon.
 void addTrayListener(TrayIconListener listener)
          Adds a specified tray icon listener.
 void dispose()
          Disposes a tray icon.
 javax.swing.JPopupMenu getPopupMenu()
          Returns the set popup menu for the tray icon or null if it is not present.
 void removePopupMenu()
          Removes the tray icon popup menu.
 void removeTrayListener(BalloonListener listener)
          Removes specified balloon events listener.
 void removeTrayListener(java.awt.event.MouseListener listener)
          Removes specified mouse listener.
 void removeTrayListener(TrayIconListener listener)
          Removes a specified listener.
 void setIcon(Icon icon)
          Sets an icon in the system tray.
 void setPopupMenu(javax.swing.JPopupMenu popupMenu)
          Sets up a popup menu for the tray icon.
 void setToolTip(java.lang.String tip)
          Sets up a tooltip for the tray icon.
 void setVisible(boolean visible)
          Shows or hides an icon in the system tray.
 void showMessage(TrayMessage value)
          Sets and shows a balloon message.
 
Methods inherited from class java.awt.Component
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addMouseWheelListener, addNotify, addPropertyChangeListener, addPropertyChangeListener, applyComponentOrientation, areFocusTraversalKeysSet, bounds, checkImage, checkImage, coalesceEvents, contains, contains, createImage, createImage, createVolatileImage, createVolatileImage, deliverEvent, disable, disableEvents, dispatchEvent, doLayout, enable, enable, enableEvents, enableInputMethods, firePropertyChange, firePropertyChange, firePropertyChange, getAccessibleContext, getAlignmentX, getAlignmentY, getBackground, getBounds, getBounds, getColorModel, getComponentAt, getComponentAt, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusCycleRootAncestor, getFocusListeners, getFocusTraversalKeys, getFocusTraversalKeysEnabled, getFont, getFontMetrics, getForeground, getGraphics, getGraphicsConfiguration, getHeight, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputContext, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getListeners, getLocale, getLocation, getLocation, getLocationOnScreen, getMaximumSize, getMinimumSize, getMouseListeners, getMouseMotionListeners, getMouseWheelListeners, getName, getParent, getPeer, getPreferredSize, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getSize, getToolkit, getTreeLock, getWidth, getX, getY, gotFocus, handleEvent, hasFocus, hide, imageUpdate, inside, invalidate, isBackgroundSet, isCursorSet, isDisplayable, isDoubleBuffered, isEnabled, isFocusable, isFocusCycleRoot, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, isOpaque, isShowing, isValid, isVisible, keyDown, keyUp, layout, list, list, list, list, list, locate, location, lostFocus, minimumSize, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paint, paintAll, paramString, postEvent, preferredSize, prepareImage, prepareImage, print, printAll, processComponentEvent, processEvent, processFocusEvent, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, processKeyEvent, processMouseEvent, processMouseMotionEvent, processMouseWheelEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removeNotify, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, repaint, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, reshape, resize, resize, setBackground, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setEnabled, setFocusable, setFocusTraversalKeys, setFocusTraversalKeysEnabled, setFont, setForeground, setIgnoreRepaint, setLocale, setLocation, setLocation, setName, setSize, setSize, show, show, size, toString, transferFocus, transferFocusBackward, transferFocusUpCycle, update, validate
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

WM_TRAY

public static final int WM_TRAY
See Also:
Constant Field Values

WM_RESTORE_TRAY

public static final int WM_RESTORE_TRAY
Constructor Detail

TrayIcon

public TrayIcon()

TrayIcon

public TrayIcon(Icon icon)
Creates an instance of TrayIcon with a specified icon.

Parameters:
icon -
Method Detail

setIcon

public void setIcon(Icon icon)
Sets an icon in the system tray.

Parameters:
icon -

showMessage

public void showMessage(TrayMessage value)
Sets and shows a balloon message.

Parameters:
value - is a container of the ballon message attributes.

dispose

public void dispose()
Disposes a tray icon.


setToolTip

public void setToolTip(java.lang.String tip)
Sets up a tooltip for the tray icon.

Parameters:
tip - is a message to be shown in the tooltip.

setPopupMenu

public void setPopupMenu(javax.swing.JPopupMenu popupMenu)
Sets up a popup menu for the tray icon. The popup menu activates by right mouse click. NOTE: for correct displaying of the popup menu it is required to set up -Djavax.swing.adjustPopupLocationToFit=false parameter for an application.

Parameters:
popupMenu - the popup menu to be set up.

getPopupMenu

public javax.swing.JPopupMenu getPopupMenu()
Returns the set popup menu for the tray icon or null if it is not present.

Returns:
the set popup menu for the tray icon or null if it is not present.

removePopupMenu

public void removePopupMenu()
Removes the tray icon popup menu.


addTrayListener

public void addTrayListener(TrayIconListener listener)
Adds a specified tray icon listener.

Parameters:
listener -

addTrayListener

public void addTrayListener(java.awt.event.MouseListener listener)
Adds a standard mouse listener for the tray icon.

Parameters:
listener -

addTrayListener

public void addTrayListener(BalloonListener listener)
Adds a balloon events listener for the specified tray icon.

Parameters:
listener -

removeTrayListener

public void removeTrayListener(TrayIconListener listener)
Removes a specified listener.

Parameters:
listener -

removeTrayListener

public void removeTrayListener(java.awt.event.MouseListener listener)
Removes specified mouse listener.

Parameters:
listener -

removeTrayListener

public void removeTrayListener(BalloonListener listener)
Removes specified balloon events listener.

Parameters:
listener -

setVisible

public void setVisible(boolean visible)
Shows or hides an icon in the system tray.

Parameters:
visible -