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

public Class TreeItem

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

Instances of this class represent a selectable user interface object that represents a hierarchy of tree items in a tree widget.
Styles:
(none)
Events:
(none)

Important Note

This class is not intended to be subclassed.

See Also
Tree, TreeItem, TreeColumn snippets, Sample code and further information

Field Summary

Modifier and TypeField and Description
pack-priv boolean
pack-priv Font[]
pack-priv static final int
pack-priv Font
pack-priv boolean
pack-priv boolean
pack-priv Tree
pack-priv boolean
pack-priv String[]
pack-priv boolean
Inherited from org.eclipse.swt.widgets.Item:
ELLIPSISimagetextTEXT_LIMIT

Constructor Summary

AccessConstructor and Description
public
TreeItem(Tree
a tree control which will be the parent of the new instance (cannot be null)
parent
,
int
no styles are currently supported, pass SWT.NONE
style
)

Constructs TreeItem and inserts it into Tree.

public
TreeItem(Tree
a tree control which will be the parent of the new instance (cannot be null)
parent
,
int
no styles are currently supported, pass SWT.NONE
style
,
int
the zero-relative index to store the receiver in its parent
index
)

Constructs TreeItem and inserts it into Tree.

public
TreeItem(TreeItem
a tree control which will be the parent of the new instance (cannot be null)
parentItem
,
int
no styles are currently supported, pass SWT.NONE
style
)

Constructs TreeItem and inserts it into Tree.

public
TreeItem(TreeItem
a tree control which will be the parent of the new instance (cannot be null)
parentItem
,
int
no styles are currently supported, pass SWT.NONE
style
,
int
the zero-relative index to store the receiver in its parent
index
)

Constructs TreeItem and inserts it into Tree.

pack-priv
TreeItem(Tree parent, long parentIter, int style, int index, long iter)

Method Summary

Modifier and TypeMethod and Description
pack-priv Color
pack-priv Color
_getBackground(int index)

pack-priv boolean
pack-priv Color
pack-priv Color
_getForeground(int index)

pack-priv Image
_getImage(int index)

pack-priv String
_getText(int index)

pack-priv static int
checkIndex(int index)

pack-priv static TreeItem
pack-priv static Tree
checkNull(Tree control)

protected void
checkSubclass()

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

Checks that this class can be subclassed.
pack-priv void
public void
clear(int
the index of the item to clear
index
,
boolean
true if all child items of the indexed item should be cleared recursively, and false otherwise
all
)

Clears the item at the given zero-relative index in the receiver.

public void
clearAll(boolean
true if all child items should be cleared recursively, and false otherwise
all
)

Clears all the items in the receiver.

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.
public Color

Returns:

the background color
getBackground
()

Returns the receiver's background color.

public Color

Returns:

the background color
getBackground
(int
the column index
index
)

Returns the background color at the given column index in the receiver.

public Rectangle

Returns:

the receiver's bounding column rectangle
getBounds
(int
the index that specifies the column
index
)

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

public Rectangle

Returns:

the bounding rectangle of the receiver's text
getBounds
()

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

pack-priv Rectangle
getBoundsInPixels(int index)

pack-priv Rectangle
public boolean

Returns:

the checked state
getChecked
()

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

public boolean

Returns:

the expanded state
getExpanded
()

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

public Font

Returns:

the receiver's font
getFont
()

Returns the font that the receiver will use to paint textual information for this item.

public Font

Returns:

the receiver's font
getFont
(int
the column index
index
)

Returns the font that the receiver will use to paint textual information for the specified cell in this item.

public Color

Returns:

the receiver's foreground color
getForeground
()

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

public Color

Returns:

the foreground color
getForeground
(int
the column index
index
)

Returns the foreground color at the given column index in the receiver.

public boolean

Returns:

the grayed state of the checkbox
getGrayed
()

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

public Image
getImage()

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

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

Returns:

the image stored at the given column index in the receiver
getImage
(int
the column index
index
)

Returns the image stored at the given column index in the receiver, or null if the image has not been set or if the column does not exist.

public Rectangle

Returns:

the receiver's bounding image rectangle
getImageBounds
(int
the index that specifies the column
index
)

Returns a rectangle describing the size and location relative to its parent of an image at a column in the tree.

pack-priv Rectangle
public TreeItem

Returns:

the item at the given index
getItem
(int
the index of the item to return
index
)

Returns the item at the given, zero-relative index in the receiver.

public int

Returns:

the number of items
getItemCount
()

Returns the number of items contained in the receiver that are direct item children of the receiver.

public TreeItem[]

Returns:

the receiver's items
getItems
()

Returns a (possibly empty) array of TreeItems which are the direct item children of the receiver.

pack-priv String
public Tree

Returns:

the receiver's parent
getParent
()

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

public TreeItem

Returns:

the receiver's parent item
getParentItem
()

Returns the receiver's parent item, which must be a TreeItem or null when the receiver is a root.

public String
getText()

Overrides org.eclipse.swt.widgets.Item.getText.

Returns the receiver's text, which will be an empty string if it has never been set.
public String

Returns:

the text stored at the given column index in the receiver
getText
(int
the column index
index
)

Returns the text stored at the given column index in the receiver, or empty string if the text has not been set.

public Rectangle

Returns:

the receiver's bounding text rectangle
getTextBounds
(int
the index that specifies the column
index
)

Returns a rectangle describing the size and location relative to its parent of the text at a column in the tree.

pack-priv Rectangle
public int

Returns:

the index of the item
indexOf
(TreeItem
the search item
item
)

Searches the receiver's list starting at the first item (index 0) until an item is found that is equal to the argument, and returns the index of that item.

pack-priv void
pack-priv void
pack-priv void
public void
removeAll()

Removes all of the items from the receiver.

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 item if the argument is null.

public void
setBackground(int
the column index
index
,
Color
the new color (or null)
color
)

Sets the background color at the given column index in the receiver to the color specified by the argument, or to the default system color for the item if the argument is null.

public void
setChecked(boolean
the new checked state
checked
)

Sets the checked state of the receiver.

public void
setExpanded(boolean
the new expanded state
expanded
)

Sets the expanded state of the receiver.

public void
setFont(Font
the new font (or null)
font
)

Sets the font that the receiver will use to paint textual information for this item to the font specified by the argument, or to the default font for that kind of control if the argument is null.

public void
setFont(int
the column index
index
,
Font
the new font (or null)
font
)

Sets the font that the receiver will use to paint textual information for the specified cell in this item to the font specified by the argument, or to the default font for that kind of control if the argument is null.

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 item if the argument is null.

public void
setForeground(int
the column index
index
,
Color
the new color (or null)
color
)

Sets the foreground color at the given column index in the receiver to the color specified by the argument, or to the default system color for the item if the argument is null.

public void
setGrayed(boolean
the new grayed state of the checkbox
grayed
)

Sets the grayed state of the checkbox for this item.

public void
setImage(int
the column index
index
,
Image
the new image
image
)

Sets the receiver's image at a column.

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.
public void
setImage(Image[]
the array of new images
images
)

Sets the image for multiple columns in the tree.

public void
setItemCount(int
the number of items
count
)

Sets the number of child items contained in the receiver.

public void
setText(int
the column index
index
,
String
the new text
string
)

Sets the receiver's text at a column

Note

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

public void
setText(String
the new text
string
)

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

Sets the receiver's text.
public void
setText(String[]
the array of new strings
strings
)

Sets the text for multiple columns in the tree.

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

Field Detail

cachedback to summary
pack-priv boolean cached
cellFontback to summary
pack-priv Font[] cellFont
EXPANDER_EXTRA_PADDINGback to summary
pack-priv static final int EXPANDER_EXTRA_PADDING
fontback to summary
pack-priv Font font
grayedback to summary
pack-priv boolean grayed
isExpandedback to summary
pack-priv boolean isExpanded
parentback to summary
pack-priv Tree parent
settingDataback to summary
pack-priv boolean settingData
stringsback to summary
pack-priv String[] strings
updatedback to summary
pack-priv boolean updated

Constructor Detail

TreeItemback to summary
public TreeItem(Tree parent, int style)

Constructs TreeItem and inserts it into Tree. Item is inserted as last direct child of the tree.

The fastest way to insert many items is documented in TreeItem#TreeItem(Tree, int, int) and TreeItem#setItemCount

Parameters
parent:Tree

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

style:int

no styles are currently supported, pass SWT.NONE

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
TreeItemback to summary
public TreeItem(Tree parent, int style, int index)

Constructs TreeItem and inserts it into Tree. Item is inserted as index direct child of the tree.

The fastest way to insert many items is:

  1. Use Tree#setRedraw to disable drawing during bulk insert
  2. Insert every item at index 0 (insert them in reverse to get the same result)
  3. Collapse the parent item before inserting (gives massive improvement on Windows)
Parameters
parent:Tree

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

style:int

no styles are currently supported, pass SWT.NONE

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, Widget#checkSubclass, Widget#getStyle, Tree#setRedraw
TreeItemback to summary
public TreeItem(TreeItem parentItem, int style)

Constructs TreeItem and inserts it into Tree. Item is inserted as last direct child of the specified TreeItem.

The fastest way to insert many items is documented in TreeItem#TreeItem(Tree, int, int) and TreeItem#setItemCount

Parameters
parentItem:TreeItem

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

style:int

no styles are currently supported, pass SWT.NONE

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
TreeItemback to summary
public TreeItem(TreeItem parentItem, int style, int index)

Constructs TreeItem and inserts it into Tree. Item is inserted as index direct child of the specified TreeItem.

The fastest way to insert many items is documented in TreeItem#TreeItem(Tree, int, int) and TreeItem#setItemCount

Parameters
parentItem:TreeItem

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

style:int

no styles are currently supported, pass SWT.NONE

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, Widget#checkSubclass, Widget#getStyle, Tree#setRedraw
TreeItemback to summary
pack-priv TreeItem(Tree parent, long parentIter, int style, int index, long iter)

Method Detail

_getBackgroundback to summary
pack-priv Color _getBackground()
_getBackgroundback to summary
pack-priv Color _getBackground(int index)
_getCheckedback to summary
pack-priv boolean _getChecked()
_getForegroundback to summary
pack-priv Color _getForeground()
_getForegroundback to summary
pack-priv Color _getForeground(int index)
_getImageback to summary
pack-priv Image _getImage(int index)
_getTextback to summary
pack-priv String _getText(int index)
checkIndexback to summary
pack-priv static int checkIndex(int index)
checkNullback to summary
pack-priv static TreeItem checkNull(TreeItem item)
checkNullback to summary
pack-priv static Tree checkNull(Tree control)
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
clearback to summary
pack-priv void clear()
clearback to summary
public void clear(int index, boolean all)

Clears the item at the given zero-relative index in the receiver. The text, icon and other attributes of the item are set to the default value. If the tree was created with the SWT.VIRTUAL style, these attributes are requested again as needed.

Parameters
index:int

the index of the item to clear

all:boolean

true if all child items of the indexed item should be cleared recursively, and false otherwise

Exceptions
IllegalArgumentException:
  • ERROR_INVALID_RANGE - if the index is not between 0 and the number of elements in the list minus 1 (inclusive)
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
See Also
SWT#VIRTUAL, SWT#SetData
clearAllback to summary
public void clearAll(boolean all)

Clears all the items in the receiver. The text, icon and other attributes of the items are set to their default values. If the tree was created with the SWT.VIRTUAL style, these attributes are requested again as needed.

Parameters
all:boolean

true if all child items should be cleared recursively, and false otherwise

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
See Also
SWT#VIRTUAL, SWT#SetData
destroyWidgetback to summary
pack-priv void destroyWidget()

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

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
getBackgroundback to summary
public Color getBackground()

Returns the receiver's background 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
2.0
getBackgroundback to summary
public Color getBackground(int index)

Returns the background color at the given column index in the receiver.

Parameters
index:int

the column index

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

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

Parameters
index:int

the index that specifies the column

Returns:Rectangle

the receiver's bounding column 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
Since
3.1
getBoundsback to summary
public Rectangle getBounds()

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

Returns:Rectangle

the bounding rectangle of the receiver's 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
getBoundsInPixelsback to summary
pack-priv Rectangle getBoundsInPixels(int index)
getBoundsInPixelsback to summary
pack-priv Rectangle getBoundsInPixels()
getCheckedback to summary
public boolean getChecked()

Returns true if the receiver is checked, and false otherwise. When the parent does not have the CHECK style, return false.

Returns:boolean

the checked 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
getExpandedback to summary
public boolean getExpanded()

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

Returns:boolean

the expanded 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
getFontback to summary
public Font getFont()

Returns the font that the receiver will use to paint textual information for this item.

Returns:Font

the receiver's font

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.0
getFontback to summary
public Font getFont(int index)

Returns the font that the receiver will use to paint textual information for the specified cell in this item.

Parameters
index:int

the column index

Returns:Font

the receiver's font

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.1
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
2.0
getForegroundback to summary
public Color getForeground(int index)

Returns the foreground color at the given column index in the receiver.

Parameters
index:int

the column index

Returns:Color

the 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.1
getGrayedback to summary
public boolean getGrayed()

Returns true if the receiver is grayed, and false otherwise. When the parent does not have the CHECK style, return false.

Returns:boolean

the grayed state of the checkbox

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.

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

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

Returns:Image

the receiver's image

Annotations
@Override
getImageback to summary
public Image getImage(int index)

Returns the image stored at the given column index in the receiver, or null if the image has not been set or if the column does not exist.

Parameters
index:int

the column index

Returns:Image

the image stored at the given column index in the receiver

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.1
getImageBoundsback to summary
public Rectangle getImageBounds(int index)

Returns a rectangle describing the size and location relative to its parent of an image at a column in the tree.

Parameters
index:int

the index that specifies the column

Returns:Rectangle

the receiver's bounding image 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
Since
3.1
getImageBoundsInPixelsback to summary
pack-priv Rectangle getImageBoundsInPixels(int index)
getItemback to summary
public TreeItem getItem(int index)

Returns the item at the given, zero-relative index in the receiver. Throws an exception if the index is out of range.

Parameters
index:int

the index of the item to return

Returns:TreeItem

the item at the given index

Exceptions
IllegalArgumentException:
  • ERROR_INVALID_RANGE - if the index is not between 0 and the number of elements in the list minus 1 (inclusive)
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.1
getItemCountback to summary
public int getItemCount()

Returns the number of items contained in the receiver that are direct item children of the receiver.

Returns:int

the number of items

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
getItemsback to summary
public TreeItem[] getItems()

Returns a (possibly empty) array of TreeItems which are the direct item children of the receiver.

Note

This is not the actual structure used by the receiver to maintain its list of items, so modifying the array will not affect the receiver.

Returns:TreeItem[]

the receiver's items

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 Tree getParent()

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

Returns:Tree

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
getParentItemback to summary
public TreeItem getParentItem()

Returns the receiver's parent item, which must be a TreeItem or null when the receiver is a root.

Returns:TreeItem

the receiver's parent item

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
getTextback to summary
public String getText()

Overrides org.eclipse.swt.widgets.Item.getText.

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

Returns the receiver's text, which will be an empty string if it has never been set.

Returns:String

the receiver's text

Annotations
@Override
getTextback to summary
public String getText(int index)

Returns the text stored at the given column index in the receiver, or empty string if the text has not been set.

Parameters
index:int

the column index

Returns:String

the text stored at the given column index in the receiver

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.1
getTextBoundsback to summary
public Rectangle getTextBounds(int index)

Returns a rectangle describing the size and location relative to its parent of the text at a column in the tree.

Parameters
index:int

the index that specifies the column

Returns:Rectangle

the receiver's bounding text 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
Since
3.3
getTextBoundsInPixelsback to summary
pack-priv Rectangle getTextBoundsInPixels(int index)
indexOfback to summary
public int indexOf(TreeItem item)

Searches the receiver's list starting at the first item (index 0) until an item is found that is equal to the argument, and returns the index of that item. If no item is found, returns -1.

Parameters
item:TreeItem

the search item

Returns:int

the index of the item

Exceptions
IllegalArgumentException:
  • ERROR_NULL_ARGUMENT - if the item is null
  • ERROR_INVALID_ARGUMENT - if the item 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.1
releaseChildrenback to summary
pack-priv void releaseChildren(boolean destroy)

Overrides org.eclipse.swt.widgets.Widget.releaseChildren.

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
removeAllback to summary
public void removeAll()

Removes all of the items from the receiver.

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.1
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 item if the argument is null.

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
2.0
setBackgroundback to summary
public void setBackground(int index, Color color)

Sets the background color at the given column index in the receiver to the color specified by the argument, or to the default system color for the item if the argument is null.

Parameters
index:int

the column index

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.1
setCheckedback to summary
public void setChecked(boolean checked)

Sets the checked state of the receiver.

Parameters
checked:boolean

the new checked 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
setExpandedback to summary
public void setExpanded(boolean expanded)

Sets the expanded state of the receiver.

Parameters
expanded:boolean

the new expanded 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
setFontback to summary
public void setFont(Font font)

Sets the font that the receiver will use to paint textual information for this item to the font specified by the argument, or to the default font for that kind of control if the argument is null.

Parameters
font:Font

the new font (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.0
setFontback to summary
public void setFont(int index, Font font)

Sets the font that the receiver will use to paint textual information for the specified cell in this item to the font specified by the argument, or to the default font for that kind of control if the argument is null.

Parameters
index:int

the column index

font:Font

the new font (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.1
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 item if the argument is null.

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
2.0
setForegroundback to summary
public void setForeground(int index, Color color)

Sets the foreground color at the given column index in the receiver to the color specified by the argument, or to the default system color for the item if the argument is null.

Parameters
index:int

the column index

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.1
setGrayedback to summary
public void setGrayed(boolean grayed)

Sets the grayed state of the checkbox for this item. This state change only applies if the Tree was created with the SWT.CHECK style.

Parameters
grayed:boolean

the new grayed state of the checkbox

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

Sets the receiver's image at a column.

Parameters
index:int

the column index

image:Image

the new 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.1
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
setImageback to summary
public void setImage(Image[] images)

Sets the image for multiple columns in the tree.

Parameters
images:Image[]

the array of new images

Exceptions
IllegalArgumentException:
  • ERROR_NULL_ARGUMENT - if the array of images is null
  • ERROR_INVALID_ARGUMENT - if one of the images 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.1
setItemCountback to summary
public void setItemCount(int count)

Sets the number of child items contained in the receiver.

The fastest way to insert many items is:

  1. Use Tree#setRedraw to disable drawing during bulk insert
  2. Collapse the parent item before inserting (gives massive improvement on Windows)
Parameters
count:int

the number of items

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
setTextback to summary
public void setText(int index, String string)

Sets the receiver's text at a column

Note

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

Parameters
index:int

the column index

string:String

the new text

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
Since
3.1
setTextback to summary
public void setText(String string)

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

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

Sets the receiver's text.

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
setTextback to summary
public void setText(String[] strings)

Sets the text for multiple columns in the tree.

Note

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

Parameters
strings:String[]

the array of new strings

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
Since
3.1