Package org.eclipse.swt.widgets
Class TrayItem
- java.lang.Object
-
- org.eclipse.swt.widgets.Widget
-
- org.eclipse.swt.widgets.Item
-
- org.eclipse.swt.widgets.TrayItem
-
- All Implemented Interfaces:
Adaptable
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:
- 1.4
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddMenuDetectListener(MenuDetectListener listener)Adds the listener to the collection of listeners who will be notified when the platform-specific context menu trigger has occurred, by sending it one of the messages defined in theMenuDetectListenerinterface.voidaddSelectionListener(SelectionListener listener)Adds the listener to the collection of listeners who will be notified when the receiver is selected by the user, by sending it one of the messages defined in theSelectionListenerinterface.TraygetParent()Returns the receiver's parent, which must be aTray.ToolTipgetToolTip()Returns the receiver's tool tip, or null if it has not been set.java.lang.StringgetToolTipText()Returns the receiver's tool tip text, or null if it has not been set.booleangetVisible()Returnstrueif the receiver is visible andfalseotherwise.voidremoveMenuDetectListener(MenuDetectListener listener)Removes the listener from the collection of listeners who will be notified when the platform-specific context menu trigger has occurred.voidremoveSelectionListener(SelectionListener listener)Removes the listener from the collection of listeners who will be notified when the receiver is selected by the user.voidsetToolTip(ToolTip toolTip)Sets the receiver's tool tip to the argument, which may be null indicating that no tool tip should be shown.voidsetToolTipText(java.lang.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.voidsetVisible(boolean visible)Makes the receiver visible if the argument istrue, and makes it invisible otherwise.-
Methods inherited from class org.eclipse.swt.widgets.Widget
addDisposeListener, addListener, checkSubclass, checkWidget, dispose, getAdapter, getData, getData, getDisplay, getListeners, getStyle, isDisposed, isListening, notifyListeners, removeDisposeListener, removeListener, removeListener, reskin, setData, setData, toString
-
-
-
-
Constructor Detail
-
TrayItem
public TrayItem(Tray parent, int style)
Constructs a new instance of this class given its parent (which must be aTray) 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
SWTwhich is applicable to instances of this class, or must be built by bitwise OR'ing together (that is, using theint"|" operator) two or more of thoseSWTstyle 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:
java.lang.IllegalArgumentException-- ERROR_NULL_ARGUMENT - if the parent is null
SWTException-- ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the parent
- ERROR_INVALID_SUBCLASS - if this class is not an allowed subclass
- Since:
- 1.4
- See Also:
SWT,Widget.checkSubclass(),Widget.getStyle()
-
-
Method Detail
-
getParent
public Tray getParent()
Returns the receiver's parent, which must be aTray.- Returns:
- the receiver's parent
- 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
- Since:
- 1.4
-
addSelectionListener
public void addSelectionListener(SelectionListener listener)
Adds the listener to the collection of listeners who will be notified when the receiver is selected by the user, by sending it one of the messages defined in theSelectionListenerinterface.widgetSelectedis called when the receiver is selectedwidgetDefaultSelectedis called when the receiver is double-clicked- Parameters:
listener- the listener which should be notified when the receiver is selected by the user- Throws:
java.lang.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
- Since:
- 1.4
- See Also:
SelectionListener,removeSelectionListener(org.eclipse.swt.events.SelectionListener),SelectionEvent
-
getToolTipText
public java.lang.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
- Since:
- 1.4
-
getVisible
public boolean getVisible()
Returnstrueif the receiver is visible andfalseotherwise.- 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
- Since:
- 1.4
-
removeSelectionListener
public void removeSelectionListener(SelectionListener listener)
Removes the listener from the collection of listeners who will be notified when the receiver is selected by the user.- Parameters:
listener- the listener which should no longer be notified- Throws:
java.lang.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
- Since:
- 1.4
- See Also:
SelectionListener,addSelectionListener(org.eclipse.swt.events.SelectionListener)
-
setToolTipText
public void setToolTipText(java.lang.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
- Since:
- 1.4
-
setVisible
public void setVisible(boolean visible)
Makes the receiver visible if the argument istrue, 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
- Since:
- 1.4
-
addMenuDetectListener
public void addMenuDetectListener(MenuDetectListener listener)
Adds the listener to the collection of listeners who will be notified when the platform-specific context menu trigger has occurred, by sending it one of the messages defined in theMenuDetectListenerinterface.- Parameters:
listener- the listener which should be notified- Throws:
java.lang.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
- Since:
- 1.4
- See Also:
MenuDetectListener,removeMenuDetectListener(org.eclipse.swt.events.MenuDetectListener)
-
removeMenuDetectListener
public void removeMenuDetectListener(MenuDetectListener listener)
Removes the listener from the collection of listeners who will be notified when the platform-specific context menu trigger has occurred.- Parameters:
listener- the listener which should no longer be notified- Throws:
java.lang.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
- Since:
- 1.4
- See Also:
MenuDetectListener,addMenuDetectListener(org.eclipse.swt.events.MenuDetectListener)
-
setToolTip
public void setToolTip(ToolTip toolTip)
Sets the receiver's tool tip to the argument, which may be null indicating that no tool tip should be shown.- Parameters:
toolTip- the new tool tip (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
- Since:
- 1.4
-
getToolTip
public ToolTip getToolTip()
Returns the receiver's tool tip, 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
- Since:
- 1.4
-
-