Class TrayItem
- Styles:
- (none)
- Events:
- DefaultSelection, MenuDetect, Selection
IMPORTANT: This class is not intended to be subclassed.
- Since:
- 3.0
- See Also:
- Restriction:
- This class is not intended to be subclassed by clients.
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
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 theMenuDetectListener
interface.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 theSelectionListener
interface.protected void
Checks that this class can be subclassed.Returns the receiver's highlight image if it has one, or null if it does not.Returns the receiver's parent, which must be aTray
.Returns the receiver's tool tip, or null if it has not been set.Returns the receiver's tool tip text, or null if it has not been set.boolean
Returnstrue
if the receiver is visible andfalse
otherwise.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.void
removeSelectionListener
(SelectionListener listener) Removes the listener from the collection of listeners who will be notified when the receiver is selected by the user.void
setHighlightImage
(Image image) Sets the receiver's highlight image.void
Sets the receiver's image.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.void
setToolTipText
(String string) Sets the receiver's tool tip text to the argument, which may be null indicating that the default tool tip for the control will be shown.void
setVisible
(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, addTypedListener, checkWidget, dispose, getData, getData, getDisplay, getListeners, getStyle, getTypedListeners, isAutoDirection, isDisposed, isListening, notifyListeners, removeDisposeListener, removeListener, removeListener, removeTypedListener, reskin, setData, setData, toString
-
Constructor Details
-
TrayItem
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
SWT
which 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 thoseSWT
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
-- 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
- See Also:
-
-
Method Details
-
addSelectionListener
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 theSelectionListener
interface.widgetSelected
is called when the receiver is selectedwidgetDefaultSelected
is called when the receiver is double-clicked- Parameters:
listener
- the listener which should be notified when the receiver is selected by the user- 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:
-
addMenuDetectListener
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 theMenuDetectListener
interface.- 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
- Since:
- 3.3
- See Also:
-
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
andCanvas
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 classItem
-
getHighlightImage
Returns the receiver's highlight image if it has one, or null if it does not.- Returns:
- the receiver's highlight image
- 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:
- 3.8
-
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:
- 3.2
-
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:
- 3.2
-
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()Returnstrue
if the receiver is visible andfalse
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
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:
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:
-
removeMenuDetectListener
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:
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:
- 3.3
- See Also:
-
setHighlightImage
Sets the receiver's highlight image.- Parameters:
image
- the new highlight 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
- Since:
- 3.8
-
setImage
Sets the receiver's image.- Overrides:
setImage
in classItem
- 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
-
setToolTip
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:
- 3.2
-
setToolTipText
Sets the receiver's tool tip text to the argument, which may be null indicating that the default tool tip for the control will be shown. For a control that has a default tool tip, such as the Tree control on Windows, setting the tool tip text to an empty string replaces the default, causing no tool tip text to be shown.The mnemonic indicator (character '&') is not displayed in a tool tip. To display a single '&' in the tool tip, the character '&' can be escaped by doubling it in the string.
NOTE: This operation is a hint and behavior is platform specific, on Windows for CJK-style mnemonics of the form " (&C)" at the end of the tooltip text are not shown in tooltip.
- Parameters:
string
- 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 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
-