Top Description Fields Constructors Methods
org.eclipse.swt.widgets

public Class TrayItem

extends Item
Class Inheritance
Imports
org.eclipse.swt.*, org.eclipse.swt.events.*, org.eclipse.swt.graphics.*, org.eclipse.swt.internal.*, org.eclipse.swt.internal.gtk.*, org.eclipse.swt.internal.gtk3.*

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 Note

This class is not intended to be subclassed.

Since
3.0
See Also
Tray, TrayItem snippets, Sample code and further information

Field Summary

Modifier and TypeField and Description
pack-priv Image
pack-priv long
pack-priv ImageList
pack-priv Tray
pack-priv ToolTip
pack-priv long
pack-priv String
Inherited from org.eclipse.swt.widgets.Item:
ELLIPSISimagetextTEXT_LIMIT

Constructor Summary

AccessConstructor and Description
public
TrayItem(Tray
a composite control which will be the parent of the new instance (cannot be null)
parent
,
int
the style of control to construct
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

Modifier and TypeMethod and Description
public void
addMenuDetectListener(MenuDetectListener
the listener which should be notified
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 the MenuDetectListener interface.

public void
addSelectionListener(SelectionListener
the listener which should be notified when the receiver is selected by the user
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 the SelectionListener interface.

protected void
checkSubclass()

Overrides org.eclipse.swt.widgets.Item.checkSubclass.

Checks that this class can be subclassed.
pack-priv void
pack-priv void
pack-priv void
pack-priv void
public Image

Returns:

the receiver's highlight image
getHighlightImage
()

Returns the receiver's highlight image if it has one, or null if it does not.

public Tray

Returns:

the receiver's parent
getParent
()

Returns the receiver's parent, which must be a Tray.

public ToolTip

Returns:

the receiver's tool tip text
getToolTip
()

Returns the receiver's tool tip, or null if it has not been set.

public String

Returns:

the receiver's tool tip text
getToolTipText
()

Returns the receiver's tool tip text, or null if it has not been set.

public boolean

Returns:

the receiver's visibility
getVisible
()

Returns true if the receiver is visible and false otherwise.

pack-priv long
pack-priv long
pack-priv void
gtk_gesture_press_event(long
the corresponding controller responsible for capturing the event
gesture
,
int
how many touch/button presses happened with this one
n_press
,
double
the x coordinate, in widget allocation coordinates
x
,
double
the y coordinate, in widget allocation coordinates
y
,
long
the GdkEvent captured
event
)

Overrides org.eclipse.swt.widgets.Widget.gtk_gesture_press_event.

pack-priv long
pack-priv long
gtk_status_icon_popup_menu(long widget, long button, long activate_time)

Overrides org.eclipse.swt.widgets.Widget.gtk_status_icon_popup_menu.

pack-priv void
pack-priv void
pack-priv void
pack-priv void
public void
removeMenuDetectListener(MenuDetectListener
the listener which should no longer be notified
listener
)

Removes the listener from the collection of listeners who will be notified when the platform-specific context menu trigger has occurred.

public void
removeSelectionListener(SelectionListener
the listener which should no longer be notified
listener
)

Removes the listener from the collection of listeners who will be notified when the receiver is selected by the user.

public void
setHighlightImage(Image
the new highlight image
image
)

Sets the receiver's highlight image.

public void
setImage(Image
the new image
image
)

Overrides org.eclipse.swt.widgets.Item.setImage.

Sets the receiver's image.
public void
setToolTip(ToolTip
the new tool tip (or null)
toolTip
)

Sets the receiver's tool tip to the argument, which may be null indicating that no tool tip should be shown.

public void
setToolTipText(String
the new tool tip text (or null)
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.

public void
setVisible(boolean
the new visibility state
visible
)

Makes the receiver visible if the argument is true, and makes it invisible otherwise.

Inherited from org.eclipse.swt.widgets.Item:
getImagegetNameTextgetTextsetTextupdateTextDirection

Field Detail

highlightImageback to summary
pack-priv Image highlightImage
imageHandleback to summary
pack-priv long imageHandle
imageListback to summary
pack-priv ImageList imageList
parentback to summary
pack-priv Tray parent
toolTipback to summary
pack-priv ToolTip toolTip
tooltipsHandleback to summary
pack-priv long tooltipsHandle
toolTipTextback to summary
pack-priv String toolTipText

Constructor Detail

TrayItemback to summary
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:Tray

a composite control which will be the parent of the new instance (cannot be null)

style:int

the style of control to construct

Exceptions
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
SWT, Widget#checkSubclass, Widget#getStyle

Method Detail

addMenuDetectListenerback to summary
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 the MenuDetectListener interface.

Parameters
listener:MenuDetectListener

the listener which should be notified

Exceptions
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
MenuDetectListener, removeMenuDetectListener
addSelectionListenerback to summary
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 the SelectionListener interface.

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

Parameters
listener:SelectionListener

the listener which should be notified when the receiver is selected by the user

Exceptions
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, SelectionEvent
checkSubclassback to summary
protected void checkSubclass()

Overrides org.eclipse.swt.widgets.Item.checkSubclass.

Doc from org.eclipse.swt.widgets.Widget.checkSubclass.

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 Note

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.

Annotations
@Override
createHandleback to summary
pack-priv void createHandle(int index)

Overrides org.eclipse.swt.widgets.Widget.createHandle.

Annotations
@Override
createWidgetback to summary
pack-priv void createWidget(int index)

Overrides org.eclipse.swt.widgets.Widget.createWidget.

Annotations
@Override
deregisterback to summary
pack-priv void deregister()

Overrides org.eclipse.swt.widgets.Widget.deregister.

Annotations
@Override
destroyWidgetback to summary
pack-priv void destroyWidget()

Overrides org.eclipse.swt.widgets.Widget.destroyWidget.

Annotations
@Override
getHighlightImageback to summary
public Image getHighlightImage()

Returns the receiver's highlight image if it has one, or null if it does not.

Returns:Image

the receiver's highlight image

Exceptions
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
getParentback to summary
public Tray getParent()

Returns the receiver's parent, which must be a Tray.

Returns:Tray

the receiver's parent

Exceptions
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
getToolTipback to summary
public ToolTip getToolTip()

Returns the receiver's tool tip, or null if it has not been set.

Returns:ToolTip

the receiver's tool tip text

Exceptions
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
getToolTipTextback to summary
public String getToolTipText()

Returns the receiver's tool tip text, or null if it has not been set.

Returns:String

the receiver's tool tip text

Exceptions
SWTException:
  • ERROR_WIDGET_DISPOSED - if the receiver has been disposed
  • ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver
getVisibleback to summary
public boolean getVisible()

Returns true if the receiver is visible and false otherwise.

Returns:boolean

the receiver's visibility

Exceptions
SWTException:
  • ERROR_WIDGET_DISPOSED - if the receiver has been disposed
  • ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver
gtk_activateback to summary
pack-priv long gtk_activate(long widget)

Overrides org.eclipse.swt.widgets.Widget.gtk_activate.

Annotations
@Override
gtk_button_press_eventback to summary
pack-priv long gtk_button_press_event(long widget, long event)

Overrides org.eclipse.swt.widgets.Widget.gtk_button_press_event.

Annotations
@Override
gtk_gesture_press_eventback to summary
pack-priv void gtk_gesture_press_event(long gesture, int n_press, double x, double y, long event)

Overrides org.eclipse.swt.widgets.Widget.gtk_gesture_press_event.

Parameters
gesture:long

Doc from org.eclipse.swt.widgets.Widget.gtk_gesture_press_event.

the corresponding controller responsible for capturing the event

n_press:int

Doc from org.eclipse.swt.widgets.Widget.gtk_gesture_press_event.

how many touch/button presses happened with this one

x:double

Doc from org.eclipse.swt.widgets.Widget.gtk_gesture_press_event.

the x coordinate, in widget allocation coordinates

y:double

Doc from org.eclipse.swt.widgets.Widget.gtk_gesture_press_event.

the y coordinate, in widget allocation coordinates

event:long

Doc from org.eclipse.swt.widgets.Widget.gtk_gesture_press_event.

the GdkEvent captured

Annotations
@Override
gtk_size_allocateback to summary
pack-priv long gtk_size_allocate(long widget, long allocation)

Overrides org.eclipse.swt.widgets.Widget.gtk_size_allocate.

Annotations
@Override
gtk_status_icon_popup_menuback to summary
pack-priv long gtk_status_icon_popup_menu(long widget, long button, long activate_time)

Overrides org.eclipse.swt.widgets.Widget.gtk_status_icon_popup_menu.

Annotations
@Override
hookEventsback to summary
pack-priv void hookEvents()

Overrides org.eclipse.swt.widgets.Widget.hookEvents.

Annotations
@Override
registerback to summary
pack-priv void register()

Overrides org.eclipse.swt.widgets.Widget.register.

Annotations
@Override
releaseHandleback to summary
pack-priv void releaseHandle()

Overrides org.eclipse.swt.widgets.Widget.releaseHandle.

Annotations
@Override
releaseWidgetback to summary
pack-priv void releaseWidget()

Overrides org.eclipse.swt.widgets.Item.releaseWidget.

Annotations
@Override
removeMenuDetectListenerback to summary
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:MenuDetectListener

the listener which should no longer be notified

Exceptions
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
MenuDetectListener, addMenuDetectListener
removeSelectionListenerback to summary
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:SelectionListener

the listener which should no longer be notified

Exceptions
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
setHighlightImageback to summary
public void setHighlightImage(Image image)

Sets the receiver's highlight image.

Parameters
image:Image

the new highlight image

Exceptions
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
setImageback to summary
public void setImage(Image image)

Overrides org.eclipse.swt.widgets.Item.setImage.

Sets the receiver's image.

Parameters
image:Image

the new image

Annotations
@Override
Exceptions
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
setToolTipback to summary
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:ToolTip

the new tool tip (or null)

Exceptions
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
setToolTipTextback to summary
public 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. 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:String

the new tool tip text (or null)

Exceptions
SWTException:
  • ERROR_WIDGET_DISPOSED - if the receiver has been disposed
  • ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver
setVisibleback to summary
public void setVisible(boolean visible)

Makes the receiver visible if the argument is true, and makes it invisible otherwise.

Parameters
visible:boolean

the new visibility state

Exceptions
SWTException:
  • ERROR_WIDGET_DISPOSED - if the receiver has been disposed
  • ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver