Eclipse Platform
Release 3.1

org.eclipse.swt.widgets
Class TrayItem

java.lang.Object
  extended byorg.eclipse.swt.widgets.Widget
      extended byorg.eclipse.swt.widgets.Item
          extended byorg.eclipse.swt.widgets.TrayItem

public class TrayItem
extends Item

Instances of this class represent icons that can be placed on the system tray or task bar status area.

Styles:
(none)
Events:
DefaultSelection, MenuDetect, Selection

IMPORTANT: This class is not intended to be subclassed.

Since:
3.0

Constructor Summary
TrayItem(Tray parent, int style)
          Constructs a new instance of this class given its parent (which must be a Tray) and a style value describing its behavior and appearance.
 
Method Summary
 void addSelectionListener(SelectionListener listener)
          Adds the listener to the collection of listeners who will be notified when the receiver is selected, by sending it one of the messages defined in the SelectionListener interface.
protected  void checkSubclass()
          Checks that this class can be subclassed.
 String getToolTipText()
          Returns the receiver's tool tip text, or null if it has not been set.
 boolean getVisible()
          Returns true if the receiver is visible and false otherwise.
 void removeSelectionListener(SelectionListener listener)
          Removes the listener from the collection of listeners who will be notified when the receiver is selected.
 void setImage(Image image)
          Sets the receiver's image.
 void setToolTipText(String value)
          Sets the receiver's tool tip text to the argument, which may be null indicating that no tool tip text should be shown.
 void setVisible(boolean visible)
          Makes the receiver visible if the argument is true, and makes it invisible otherwise.
 
Methods inherited from class org.eclipse.swt.widgets.Item
getImage, getText, setText
 
Methods inherited from class org.eclipse.swt.widgets.Widget
addDisposeListener, addListener, checkWidget, dispose, getData, getData, getDisplay, getStyle, isDisposed, isListening, notifyListeners, removeDisposeListener, removeListener, removeListener, setData, setData, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

TrayItem

public TrayItem(Tray parent,
                int style)
Constructs a new instance of this class given its parent (which must be a Tray) and a style value describing its behavior and appearance. The item is added to the end of the items maintained by its parent.

The style value is either one of the style constants defined in class SWT which is applicable to instances of this class, or must be built by bitwise OR'ing together (that is, using the int "|" operator) two or more of those SWT style constants. The class description lists the style constants that are applicable to the class. Style bits are also inherited from superclasses.

Parameters:
parent - a composite control which will be the parent of the new instance (cannot be null)
style - the style of control to construct
Throws:
IllegalArgumentException -
SWTException -
See Also:
SWT, Widget.checkSubclass(), Widget.getStyle()
Method Detail

addSelectionListener

public void addSelectionListener(SelectionListener listener)
Adds the listener to the collection of listeners who will be notified when the receiver is selected, by sending it one of the messages defined in the SelectionListener interface.

widgetSelected is called when the receiver is selected widgetDefaultSelected is called when the receiver is double-clicked

Parameters:
listener - the listener which should be notified
Throws:
IllegalArgumentException -
  • ERROR_NULL_ARGUMENT - if the listener is null
SWTException -
  • ERROR_WIDGET_DISPOSED - if the receiver has been disposed
  • ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver
See Also:
SelectionListener, removeSelectionListener(org.eclipse.swt.events.SelectionListener), SelectionEvent

checkSubclass

protected void checkSubclass()
Description copied from class: Widget
Checks that this class can be subclassed.

The SWT class library is intended to be subclassed only at specific, controlled points (most notably, Composite and Canvas when implementing new widgets). This method enforces this rule unless it is overridden.

IMPORTANT: By providing an implementation of this method that allows a subclass of a class which does not normally allow subclassing to be created, the implementer agrees to be fully responsible for the fact that any such subclass will likely fail between SWT releases and will be strongly platform specific. No support is provided for user-written classes which are implemented in this fashion.

The ability to subclass outside of the allowed SWT classes is intended purely to enable those not on the SWT development team to implement patches in order to get around specific limitations in advance of when those limitations can be addressed by the team. Subclassing should not be attempted without an intimate and detailed understanding of the hierarchy.

Overrides:
checkSubclass in class Item

getToolTipText

public String getToolTipText()
Returns the receiver's tool tip text, or null if it has not been set.

Returns:
the receiver's tool tip text
Throws:
SWTException -
  • ERROR_WIDGET_DISPOSED - if the receiver has been disposed
  • ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver

getVisible

public boolean getVisible()
Returns true if the receiver is visible and false otherwise.

Returns:
the receiver's visibility
Throws:
SWTException -
  • ERROR_WIDGET_DISPOSED - if the receiver has been disposed
  • ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver

removeSelectionListener

public void removeSelectionListener(SelectionListener listener)
Removes the listener from the collection of listeners who will be notified when the receiver is selected.

Parameters:
listener - the listener which should no longer be notified
Throws:
IllegalArgumentException -
  • ERROR_NULL_ARGUMENT - if the listener is null
SWTException -
  • ERROR_WIDGET_DISPOSED - if the receiver has been disposed
  • ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver
See Also:
SelectionListener, addSelectionListener(org.eclipse.swt.events.SelectionListener)

setImage

public void setImage(Image image)
Sets the receiver's image.

Overrides:
setImage in class Item
Parameters:
image - the new image
Throws:
IllegalArgumentException -
  • ERROR_INVALID_ARGUMENT - if the image has been disposed
SWTException -
  • ERROR_WIDGET_DISPOSED - if the receiver has been disposed
  • ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver

setToolTipText

public void setToolTipText(String value)
Sets the receiver's tool tip text to the argument, which may be null indicating that no tool tip text should be shown.

Parameters:
value - the new tool tip text (or null)
Throws:
SWTException -
  • ERROR_WIDGET_DISPOSED - if the receiver has been disposed
  • ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver

setVisible

public void setVisible(boolean visible)
Makes the receiver visible if the argument is true, and makes it invisible otherwise.

Parameters:
visible - the new visibility state
Throws:
SWTException -
  • ERROR_WIDGET_DISPOSED - if the receiver has been disposed
  • ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver

Eclipse Platform
Release 3.1

Guidelines for using Eclipse APIs.

Copyright (c) IBM Corp. and others 2000, 2005. All rights reserved.