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

public Class ToolItem

extends Item
Class Inheritance
Imports
java.util.*, 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.*, org.eclipse.swt.internal.gtk4.*

Instances of this class represent a selectable user interface object that represents a button in a tool bar.
Styles:
PUSH, CHECK, RADIO, SEPARATOR, DROP_DOWN
Events:
Selection

Note

Only one of the styles CHECK, PUSH, RADIO, SEPARATOR and DROP_DOWN may be specified.

Important Note

This class is not intended to be subclassed.

See Also
ToolBar, ToolItem snippets, Sample code and further information

Field Summary

Modifier and TypeField and Description
pack-priv long
pack-priv Color
pack-priv long
boxHandle

GTK4 only field, used to keep track of the containing box of the image & label

pack-priv Control
pack-priv Image
currentImage

The image that is currently used by the tool item.

pack-priv Image
pack-priv Image
pack-priv boolean
pack-priv boolean
pack-priv long
pack-priv Color
pack-priv long
groupHandle

GTK4 only field, used to keep track of the containing box of the image & label

pack-priv Image
pack-priv long
pack-priv long
pack-priv boolean
mapHooked

True iff map has been hooked for this ToolItem.

pack-priv ToolBar
pack-priv long
pack-priv long
pack-priv String
Inherited from org.eclipse.swt.widgets.Item:
ELLIPSISimagetextTEXT_LIMIT

Constructor Summary

AccessConstructor and Description
public
ToolItem(ToolBar
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 ToolBar) and a style value describing its behavior and appearance.

public
ToolItem(ToolBar
a composite control which will be the parent of the new instance (cannot be null)
parent
,
int
the style of control to construct
style
,
int
the zero-relative index to store the receiver in its parent
index
)

Constructs a new instance of this class given its parent (which must be a ToolBar), a style value describing its behavior and appearance, and the index at which to place it in the items maintained by its parent.

Method Summary

Modifier and TypeMethod and Description
private void
pack-priv void
public void
addSelectionListener(SelectionListener
the listener which should be notified when the control is selected by the user,
listener
)

Adds the listener to the collection of listeners who will be notified when the control is selected by the user, by sending it one of the messages defined in the SelectionListener interface.

pack-priv static int
checkStyle(int style)

protected void
checkSubclass()

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

Checks that this class can be subclassed.
pack-priv Widget[]
pack-priv void
pack-priv void
pack-priv void
public void
dispose()

Overrides org.eclipse.swt.widgets.Widget.dispose.

Disposes of the operating system resources associated with the receiver and all its descendants.
private void
pack-priv long
dpiChanged(long object, long arg0)

Overrides org.eclipse.swt.widgets.Widget.dpiChanged.

public Color

Returns:

the background color
getBackground
()

Returns the receiver's background color.

public Rectangle

Returns:

the receiver's bounding rectangle
getBounds
()

Returns a rectangle describing the receiver's size and location relative to its parent.

pack-priv Rectangle
public Control

Returns:

the control
getControl
()

Returns the control that is used to fill the bounds of the item when the item is a SEPARATOR.

public Image

Returns:

the receiver's disabled image
getDisabledImage
()

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

public boolean

Returns:

the receiver's enabled state
getEnabled
()

Returns true if the receiver is enabled, and false otherwise.

public Color

Returns:

the receiver's foreground color
getForeground
()

Returns the foreground color that the receiver will use to draw.

public Image

Returns:

the receiver's hot image
getHotImage
()

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

public Image

Returns:

the receiver's enabled image
getImage
()

Overrides org.eclipse.swt.widgets.Item.getImage.

Returns the receiver's enabled image if it has one, or null if it does not.
pack-priv String
public ToolBar

Returns:

the receiver's parent
getParent
()

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

public boolean

Returns:

the selection state
getSelection
()

Returns true if the receiver is selected, and false otherwise.

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 int

Returns:

the width
getWidth
()

Gets the width of the receiver.

pack-priv int
pack-priv long
pack-priv long
pack-priv long
pack-priv long
pack-priv long
pack-priv long
pack-priv long
pack-priv long
pack-priv long
pack-priv long
pack-priv long
pack-priv void
public boolean

Returns:

the receiver's enabled state
isEnabled
()

Returns true if the receiver is enabled and all of the receiver's ancestors are enabled, and false otherwise.

pack-priv boolean
private void
pack-priv void
pack-priv void
pack-priv void
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 control is selected by the user.

pack-priv void
pack-priv void
resizeHandle(int width, int height)

pack-priv void
public void
setBackground(Color
the new color (or null)
color
)

Sets the receiver's background color to the color specified by the argument, or to the default system color for the control if the argument is null.

public void
setControl(Control
the new control
control
)

Sets the control that is used to fill the bounds of the item when the item is a SEPARATOR.

public void
setDisabledImage(Image
the disabled image to display on the receiver (may be null)
image
)

Sets the receiver's disabled image to the argument, which may be null indicating that no disabled image should be displayed.

public void
setEnabled(boolean
the new enabled state
enabled
)

Enables the receiver if the argument is true, and disables it otherwise.

pack-priv boolean
pack-priv void
setFontDescription(long font)

public void
setForeground(Color
the new color (or null)
color
)

Sets the receiver's foreground color to the color specified by the argument, or to the default system color for the control if the argument is null.

public void
setHotImage(Image
the hot image to display on the receiver (may be null)
image
)

Sets the receiver's hot image to the argument, which may be null indicating that no hot image should be displayed.

public void
setImage(Image
the image to display on the receiver (may be null)
image
)

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

Sets the receiver's image to the argument, which may be null indicating that no image should be displayed.
pack-priv void
pack-priv boolean
setRadioSelection(boolean value)

public void
setSelection(boolean
the new selection state
selected
)

Sets the selection state of the receiver.

pack-priv boolean
public void
setText(String
the new text
string
)

Overrides org.eclipse.swt.widgets.Item.setText.

Sets the receiver's text.
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
setWidth(int
the new width. If the new value is SWT.DEFAULT, the width is a fixed-width area whose amount is determined by the platform. If the new value is 0 a vertical or horizontal line will be drawn, depending on the setting of the corresponding style bit (SWT.VERTICAL or SWT.HORIZONTAL). If the new value is SWT.SEPARATOR_FILL a variable-width space is inserted that acts as a spring between the two adjoining items which will push them out to the extent of the containing ToolBar.
width
)

Sets the width of the receiver, for SEPARATOR ToolItems.

pack-priv void
setWidthInPixels(int width)

pack-priv void
showWidget(int index)

pack-priv void
Inherited from org.eclipse.swt.widgets.Item:
getTextupdateTextDirection

Field Detail

arrowHandleback to summary
pack-priv long arrowHandle
backgroundback to summary
pack-priv Color background
boxHandleback to summary
pack-priv long boxHandle

GTK4 only field, used to keep track of the containing box of the image & label

controlback to summary
pack-priv Control control
currentImageback to summary
pack-priv Image currentImage

The image that is currently used by the tool item. Either the image set by client code via setImage(Image) or setDisabledImage(Image), depending on button state. Or if the button is disabled but no disabled image is specified, a grayed out version of the "normal" image.

defaultDisableImageback to summary
pack-priv Image defaultDisableImage
disabledImageback to summary
pack-priv Image disabledImage
drawHotImageback to summary
pack-priv boolean drawHotImage
enabledback to summary
pack-priv boolean enabled
eventHandleback to summary
pack-priv long eventHandle
foregroundback to summary
pack-priv Color foreground
groupHandleback to summary
pack-priv long groupHandle

GTK4 only field, used to keep track of the containing box of the image & label

hotImageback to summary
pack-priv Image hotImage
imageHandleback to summary
pack-priv long imageHandle
labelHandleback to summary
pack-priv long labelHandle
mapHookedback to summary
pack-priv boolean mapHooked

True iff map has been hooked for this ToolItem. See bug 546914.

parentback to summary
pack-priv ToolBar parent
providerback to summary
pack-priv long provider
proxyMenuItemback to summary
pack-priv long proxyMenuItem
toolTipTextback to summary
pack-priv String toolTipText

Constructor Detail

ToolItemback to summary
public ToolItem(ToolBar parent, int style)

Constructs a new instance of this class given its parent (which must be a ToolBar) 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:ToolBar

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#PUSH, SWT#CHECK, SWT#RADIO, SWT#SEPARATOR, SWT#DROP_DOWN, Widget#checkSubclass, Widget#getStyle
ToolItemback to summary
public ToolItem(ToolBar parent, int style, int index)

Constructs a new instance of this class given its parent (which must be a ToolBar), a style value describing its behavior and appearance, and the index at which to place it in 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:ToolBar

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

style:int

the style of control to construct

index:int

the zero-relative index to store the receiver in its parent

Exceptions
IllegalArgumentException:
  • ERROR_NULL_ARGUMENT - if the parent is null
  • ERROR_INVALID_RANGE - if the index is not between 0 and the number of elements in the parent (inclusive)
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#PUSH, SWT#CHECK, SWT#RADIO, SWT#SEPARATOR, SWT#DROP_DOWN, Widget#checkSubclass, Widget#getStyle

Method Detail

_setEnabledOrDisabledImageback to summary
private void _setEnabledOrDisabledImage()
_setImageback to summary
pack-priv void _setImage(Image image)
addSelectionListenerback to summary
public void addSelectionListener(SelectionListener listener)

Adds the listener to the collection of listeners who will be notified when the control is selected by the user, by sending it one of the messages defined in the SelectionListener interface.

When widgetSelected is called when the mouse is over the arrow portion of a drop-down tool, the event object detail field contains the value SWT.ARROW. widgetDefaultSelected is not called.

When the SWT.RADIO style bit is set, the widgetSelected method is also called when the receiver loses selection because another item in the same radio group was selected by the user. During widgetSelected the application can use getSelection() to determine the current selected state of the receiver.

Parameters
listener:SelectionListener

the listener which should be notified when the control 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
checkStyleback to summary
pack-priv static int checkStyle(int style)
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
computeTabListback to summary
pack-priv Widget[] computeTabList()
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
disposeback to summary
public void dispose()

Overrides org.eclipse.swt.widgets.Widget.dispose.

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

Disposes of the operating system resources associated with the receiver and all its descendants. After this method has been invoked, the receiver and all descendants will answer true when sent the message isDisposed(). Any internal connections between the widgets in the tree will have been removed to facilitate garbage collection. This method does nothing if the widget is already disposed.

Note

This method is not called recursively on the descendants of the receiver. This means that, widget implementers can not detect when a widget is being disposed of by re-implementing this method, but should instead listen for the Dispose event.

Annotations
@Override
disposeDefaultback to summary
private void disposeDefault()
dpiChangedback to summary
pack-priv long dpiChanged(long object, long arg0)

Overrides org.eclipse.swt.widgets.Widget.dpiChanged.

Annotations
@Override
getBackgroundback to summary
public Color getBackground()

Returns the receiver's background color.

Note

This operation is a hint and may be overridden by the platform. For example, on some versions of Windows the background of a TabFolder, is a gradient rather than a solid color.

Returns:Color

the background color

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.120
getBoundsback to summary
public Rectangle getBounds()

Returns a rectangle describing the receiver's size and location relative to its parent.

Returns:Rectangle

the receiver's bounding rectangle

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
getBoundsInPixelsback to summary
pack-priv Rectangle getBoundsInPixels()
getControlback to summary
public Control getControl()

Returns the control that is used to fill the bounds of the item when the item is a SEPARATOR.

Returns:Control

the control

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
getDisabledImageback to summary
public Image getDisabledImage()

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

The disabled image is displayed when the receiver is disabled.

Returns:Image

the receiver's disabled 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
getEnabledback to summary
public boolean getEnabled()

Returns true if the receiver is enabled, and false otherwise. A disabled control is typically not selectable from the user interface and draws with an inactive or "grayed" look.

Returns:boolean

the receiver's enabled 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
See Also
isEnabled
getForegroundback to summary
public Color getForeground()

Returns the foreground color that the receiver will use to draw.

Returns:Color

the receiver's foreground color

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.120
getHotImageback to summary
public Image getHotImage()

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

The hot image is displayed when the mouse enters the receiver.

Returns:Image

the receiver's hot 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
getImageback to summary
public Image getImage()

Overrides org.eclipse.swt.widgets.Item.getImage.

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

Returns:Image

the receiver's enabled image

Annotations
@Override
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
getNameTextback to summary
pack-priv String getNameText()

Overrides org.eclipse.swt.widgets.Item.getNameText.

Annotations
@Override
getParentback to summary
public ToolBar getParent()

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

Returns:ToolBar

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
getSelectionback to summary
public boolean getSelection()

Returns true if the receiver is selected, and false otherwise.

When the receiver is of type CHECK or RADIO, it is selected when it is checked (which some platforms draw as a pushed in button). If the receiver is of any other type, this method returns false.

Returns:boolean

the selection 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
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
getWidthback to summary
public int getWidth()

Gets the width of the receiver.

Returns:int

the width

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
getWidthInPixelsback to summary
pack-priv int getWidthInPixels()
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_button_release_eventback to summary
pack-priv long gtk_button_release_event(long widget, long event)

Overrides org.eclipse.swt.widgets.Widget.gtk_button_release_event.

Annotations
@Override
gtk_clickedback to summary
pack-priv long gtk_clicked(long widget)

Overrides org.eclipse.swt.widgets.Widget.gtk_clicked.

Annotations
@Override
gtk_create_menu_proxyback to summary
pack-priv long gtk_create_menu_proxy(long widget)

Overrides org.eclipse.swt.widgets.Widget.gtk_create_menu_proxy.

Annotations
@Override
gtk_enter_notify_eventback to summary
pack-priv long gtk_enter_notify_event(long widget, long event)

Overrides org.eclipse.swt.widgets.Widget.gtk_enter_notify_event.

Annotations
@Override
gtk_event_afterback to summary
pack-priv long gtk_event_after(long widget, long gdkEvent)

Overrides org.eclipse.swt.widgets.Widget.gtk_event_after.

Annotations
@Override
gtk_focus_in_eventback to summary
pack-priv long gtk_focus_in_event(long widget, long event)

Overrides org.eclipse.swt.widgets.Widget.gtk_focus_in_event.

Annotations
@Override
gtk_focus_out_eventback to summary
pack-priv long gtk_focus_out_event(long widget, long event)

Overrides org.eclipse.swt.widgets.Widget.gtk_focus_out_event.

Annotations
@Override
gtk_leave_notify_eventback to summary
pack-priv long gtk_leave_notify_event(long widget, long event)

Overrides org.eclipse.swt.widgets.Widget.gtk_leave_notify_event.

Annotations
@Override
gtk_mapback to summary
pack-priv long gtk_map(long widget)

Overrides org.eclipse.swt.widgets.Widget.gtk_map.

Annotations
@Override
gtk_mnemonic_activateback to summary
pack-priv long gtk_mnemonic_activate(long widget, long arg1)

Overrides org.eclipse.swt.widgets.Widget.gtk_mnemonic_activate.

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

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

Annotations
@Override
isEnabledback to summary
public boolean isEnabled()

Returns true if the receiver is enabled and all of the receiver's ancestors are enabled, and false otherwise. A disabled control is typically not selectable from the user interface and draws with an inactive or "grayed" look.

Returns:boolean

the receiver's enabled 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
See Also
getEnabled
isTabGroupback to summary
pack-priv boolean isTabGroup()
recreateMenuProxyback to summary
private void recreateMenuProxy()
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
removeSelectionListenerback to summary
public void removeSelectionListener(SelectionListener listener)

Removes the listener from the collection of listeners who will be notified when the control 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
resizeControlback to summary
pack-priv void resizeControl()
resizeHandleback to summary
pack-priv void resizeHandle(int width, int height)
selectRadioback to summary
pack-priv void selectRadio()
setBackgroundback to summary
public void setBackground(Color color)

Sets the receiver's background color to the color specified by the argument, or to the default system color for the control if the argument is null.

Note

This operation is a hint and may be overridden by the platform.

Parameters
color:Color

the new color (or null)

Exceptions
IllegalArgumentException:
  • ERROR_INVALID_ARGUMENT - if the argument 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.120
setControlback to summary
public void setControl(Control control)

Sets the control that is used to fill the bounds of the item when the item is a SEPARATOR.

Parameters
control:Control

the new control

Exceptions
IllegalArgumentException:
  • ERROR_INVALID_ARGUMENT - if the control has been disposed
  • ERROR_INVALID_PARENT - if the control is not in the same widget tree
SWTException:
  • ERROR_WIDGET_DISPOSED - if the receiver has been disposed
  • ERROR_THREAD_INVALID_ACCESS - if not called from the thread that created the receiver
setDisabledImageback to summary
public void setDisabledImage(Image image)

Sets the receiver's disabled image to the argument, which may be null indicating that no disabled image should be displayed.

The disabled image is displayed when the receiver is disabled.

Parameters
image:Image

the disabled image to display on the receiver (may be null)

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
setEnabledback to summary
public void setEnabled(boolean enabled)

Enables the receiver if the argument is true, and disables it otherwise.

A disabled control is typically not selectable from the user interface and draws with an inactive or "grayed" look.

Parameters
enabled:boolean

the new enabled 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
setFocusback to summary
pack-priv boolean setFocus()
setFontDescriptionback to summary
pack-priv void setFontDescription(long font)
setForegroundback to summary
public void setForeground(Color color)

Sets the receiver's foreground color to the color specified by the argument, or to the default system color for the control if the argument is null.

Note

This operation is a hint and may be overridden by the platform.

Parameters
color:Color

the new color (or null)

Exceptions
IllegalArgumentException:
  • ERROR_INVALID_ARGUMENT - if the argument 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.120
setHotImageback to summary
public void setHotImage(Image image)

Sets the receiver's hot image to the argument, which may be null indicating that no hot image should be displayed.

The hot image is displayed when the mouse enters the receiver.

Parameters
image:Image

the hot image to display on the receiver (may be null)

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

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

Doc from org.eclipse.swt.widgets.Item.setImage.

Sets the receiver's image to the argument, which may be null indicating that no image should be displayed.

Parameters
image:Image

the image to display on the receiver (may be null)

Annotations
@Override
setOrientationback to summary
pack-priv void setOrientation(boolean create)

Overrides org.eclipse.swt.widgets.Widget.setOrientation.

Annotations
@Override
setRadioSelectionback to summary
pack-priv boolean setRadioSelection(boolean value)
setSelectionback to summary
public void setSelection(boolean selected)

Sets the selection state of the receiver.

When the receiver is of type CHECK or RADIO, it is selected when it is checked (which some platforms draw as a pushed in button).

Parameters
selected:boolean

the new selection 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
setTabItemFocusback to summary
pack-priv boolean setTabItemFocus(boolean next)

Overrides org.eclipse.swt.widgets.Widget.setTabItemFocus.

Annotations
@Override
setTextback to summary
public void setText(String string)

Overrides org.eclipse.swt.widgets.Item.setText.

Sets the receiver's text. The string may include the mnemonic character.

Mnemonics are indicated by an '&' that causes the next character to be the mnemonic. When the user presses a key sequence that matches the mnemonic, a selection event occurs. On most platforms, the mnemonic appears underlined but may be emphasised in a platform specific manner. The mnemonic indicator character '&' can be escaped by doubling it in the string, causing a single '&' to be displayed.

Note

If control characters like '\n', '\t' etc. are used in the string, then the behavior is platform dependent.

Parameters
string:String

the new text

Annotations
@Override
Exceptions
IllegalArgumentException:
  • ERROR_NULL_ARGUMENT - if the text 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
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
setWidthback to summary
public void setWidth(int width)

Sets the width of the receiver, for SEPARATOR ToolItems.

Parameters
width:int

the new width. If the new value is SWT.DEFAULT, the width is a fixed-width area whose amount is determined by the platform. If the new value is 0 a vertical or horizontal line will be drawn, depending on the setting of the corresponding style bit (SWT.VERTICAL or SWT.HORIZONTAL). If the new value is SWT.SEPARATOR_FILL a variable-width space is inserted that acts as a spring between the two adjoining items which will push them out to the extent of the containing ToolBar.

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
setWidthInPixelsback to summary
pack-priv void setWidthInPixels(int width)
showWidgetback to summary
pack-priv void showWidget(int index)
updateStyleback to summary
pack-priv void updateStyle()