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

public Class Table

extends Composite
Class Inheritance
Imports
org.eclipse.swt.*, org.eclipse.swt.events.*, org.eclipse.swt.graphics.*, org.eclipse.swt.internal.*, org.eclipse.swt.internal.cairo.*, org.eclipse.swt.internal.gtk.*, org.eclipse.swt.internal.gtk3.*, org.eclipse.swt.internal.gtk4.*

Instances of this class implement a selectable user interface object that displays a list of images and strings and issues notification when selected.

The item children that may be added to instances of this class must be of type TableItem.

Style VIRTUAL is used to create a Table whose TableItems are to be populated by the client on an on-demand basis instead of up-front. This can provide significant performance improvements for tables that are very large or for which TableItem population is expensive (for example, retrieving values from an external source).

Here is an example of using a Table with style VIRTUAL:


 final Table table = new Table (parent, SWT.VIRTUAL | SWT.BORDER);
 table.setItemCount (1000000);
 table.addListener (SWT.SetData, new Listener () {
     public void handleEvent (Event event) {
         TableItem item = (TableItem) event.item;
         int index = table.indexOf (item);
         item.setText ("Item " + index);
         System.out.println (item.getText ());
     }
 });

Note that although this class is a subclass of Composite, it does not normally make sense to add Control children to it, or set a layout on it, unless implementing something like a cell editor.

Styles:
SINGLE, MULTI, CHECK, FULL_SELECTION, HIDE_SELECTION, VIRTUAL, NO_SCROLL
Events:
Selection, DefaultSelection, SetData, MeasureItem, EraseItem, PaintItem

Note

Only one of the styles SINGLE, and MULTI may be specified.

Important Note

This class is not intended to be subclassed.

See Also
Table, TableItem, TableColumn snippets, SWT Example: ControlExample, Sample code and further information

Field Summary

Modifier and TypeField and Description
pack-priv GdkRGBA
pack-priv static final int
pack-priv boolean
pack-priv double
pack-priv static final int
pack-priv static final int
pack-priv static final int
pack-priv static final int
pack-priv static final int
pack-priv static final int
pack-priv static final int
pack-priv static final int
pack-priv long
pack-priv int
pack-priv TableColumn[]
pack-priv double
pack-priv TableItem
pack-priv int
pack-priv GdkRGBA
pack-priv int
pack-priv static final int
pack-priv boolean
firstCompute

True iff computeSize has never been called on this Table

pack-priv boolean
pack-priv static final int
pack-priv GdkRGBA
pack-priv static final int
pack-priv static final int
pack-priv boolean
pack-priv Color
private long
pack-priv Color
pack-priv int
pack-priv ImageList
pack-priv boolean
pack-priv long
pack-priv boolean
pack-priv ImageList
pack-priv int
pack-priv TableItem[]
pack-priv int
pack-priv int
pack-priv long
pack-priv boolean
pack-priv int
pack-priv boolean
pack-priv int
pack-priv boolean
pack-priv int
pack-priv int
pack-priv TableColumn
pack-priv int
pack-priv int
pack-priv boolean
Inherited from org.eclipse.swt.widgets.Composite:
backgroundModechildrenLoweredembeddedHandlefixClipHandlefixClipMapimHandlelayoutlayoutCountNO_INPUT_METHODnoChildDrawingpopupChildsocketHandletabList

Constructor Summary

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

Method Summary

Modifier and TypeMethod and Description
pack-priv void
pack-priv TableItem
_getItem(int index)

public void
addSelectionListener(SelectionListener
the listener which should be notified when the user changes the receiver's selection
listener
)

Adds the listener to the collection of listeners who will be notified when the user changes the receiver's selection, by sending it one of the messages defined in the SelectionListener interface.

pack-priv int
pack-priv int
calculateWidth(long column, long iter)

pack-priv long
cellDataProc(long tree_column, long cell, long tree_model, long iter, long data)

Overrides org.eclipse.swt.widgets.Widget.cellDataProc.

pack-priv boolean
pack-priv void
checkSetDataInProcessBeforeRemoval(int
index of first item to check
start
,
int
index after the last item to check
end
)

Check the table item range [start, end) for items that are in process of sending SWT#SetData event.

pack-priv static int
protected void
checkSubclass()

Overrides org.eclipse.swt.widgets.Composite.checkSubclass.

Checks that this class can be subclassed.
public void
clear(int
the index of the item to clear
index
)

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

public void
clear(int
the start index of the item to clear
start
,
int
the end index of the item to clear
end
)

Removes the items from the receiver which are between the given zero-relative start and end indices (inclusive).

public void
clear(int[]
the array of indices of the items
indices
)

Clears the items at the given zero-relative indices in the receiver.

public void
clearAll()

Clears all the items in the receiver.

pack-priv Point
computeSizeInPixels(int wHint, int hHint, boolean changed)

Overrides org.eclipse.swt.widgets.Composite.computeSizeInPixels.

pack-priv void
copyModel(long oldModel, int oldStart, long newModel, int newStart, int modelLength)

pack-priv void
createColumn(TableColumn column, int index)

pack-priv void
pack-priv void
createItem(TableColumn column, int index)

pack-priv void
createItem(TableItem item, int index)

pack-priv void
createRenderers(long columnHandle, int modelIndex, boolean check, int columnStyle)

pack-priv void
pack-priv GdkRGBA
pack-priv void
public void
deselect(int
the index of the item to deselect
index
)

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

public void
deselect(int
the start index of the items to deselect
start
,
int
the end index of the items to deselect
end
)

Deselects the items at the given zero-relative indices in the receiver.

public void
deselect(int[]
the array of indices for the items to deselect
indices
)

Deselects the items at the given zero-relative indices in the receiver.

public void
deselectAll()

Deselects all selected items in the receiver.

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.
pack-priv boolean
dragDetect(int x, int y, boolean filter, boolean dragOnTimeout, boolean[] consume)

Overrides org.eclipse.swt.widgets.Control.dragDetect.

pack-priv void
pack-priv long
pack-priv long
pack-priv Rectangle
pack-priv int
public TableColumn

Returns:

the column at the given index
getColumn
(int
the index of the column to return
index
)

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

public int

Returns:

the number of columns
getColumnCount
()

Returns the number of columns contained in the receiver.

public int[]

Returns:

the current visual order of the receiver's items
getColumnOrder
()

Returns an array of zero-relative integers that map the creation order of the receiver's items to the order in which they are currently being displayed.

public TableColumn[]

Returns:

the items in the receiver
getColumns
()

Returns an array of TableColumns which are the columns in the receiver.

pack-priv long[]
getColumnTypes(int columnCount)

pack-priv GdkRGBA
pack-priv GdkRGBA
pack-priv TableItem
private GC
getGC(long cr)

public int

Returns:

the width of a grid line in points
getGridLineWidth
()

Returns the width in points of a grid line.

pack-priv int
public Color

Returns:

the receiver's header background color.
getHeaderBackground
()

Returns the header background color.

public Color

Returns:

the receiver's header foreground color.
getHeaderForeground
()

Returns the header foreground color.

public int

Returns:

the height of the header or zero if the header is not visible
getHeaderHeight
()

Returns the height of the receiver's header

pack-priv int
public boolean

Returns:

the receiver's header's visibility state
getHeaderVisible
()

Returns true if the receiver's header is visible, and false otherwise.

public TableItem

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 TableItem

Returns:

the item at the given point, or null if the point is not in a selectable item
getItem
(Point
the point used to locate the item
point
)

Returns the item at the given point in the receiver or null if no such item exists.

public int

Returns:

the number of items
getItemCount
()

Returns the number of items contained in the receiver.

public int

Returns:

the height of one item
getItemHeight
()

Returns the height of the area which would be used to display one of the items in the receiver.

pack-priv int
pack-priv TableItem
public TableItem[]

Returns:

the items in the receiver
getItems
()

Returns a (possibly empty) array of TableItems which are the items in the receiver.

public boolean

Returns:

the visibility state of the lines
getLinesVisible
()

Returns true if the receiver's lines are visible, and false otherwise.

pack-priv long
getPixbufRenderer(long column)

public TableItem[]

Returns:

an array representing the selection
getSelection
()

Returns an array of TableItems that are currently selected in the receiver.

public int

Returns:

the number of selected items
getSelectionCount
()

Returns the number of selected items contained in the receiver.

public int

Returns:

the index of the selected item
getSelectionIndex
()

Returns the zero-relative index of the item which is currently selected in the receiver, or -1 if no item is selected.

public int[]

Returns:

the array of indices of the selected items
getSelectionIndices
()

Returns the zero-relative indices of the items which are currently selected in the receiver.

public TableColumn

Returns:

the sort indicator
getSortColumn
()

Returns the column which shows the sort indicator for the receiver.

public int

Returns:

the sort direction
getSortDirection
()

Returns the direction of the sort indicator for the receiver.

pack-priv long
getTextRenderer(long column)

public int

Returns:

the index of the top item
getTopIndex
()

Returns the zero-relative index of the item which is currently at the top of the receiver.

pack-priv long
pack-priv long
pack-priv long
pack-priv long
gtk_draw(long widget, long cairo)

Overrides org.eclipse.swt.widgets.Composite.gtk_draw.

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.Control.gtk_gesture_press_event.

Handling multi-press event on GTK4
pack-priv long
pack-priv long
pack-priv long
gtk_row_activated(long tree, long path, long column)

Overrides org.eclipse.swt.widgets.Widget.gtk_row_activated.

pack-priv long
pack-priv long
pack-priv long
gtk_toggled(long renderer, long pathStr)

Overrides org.eclipse.swt.widgets.Widget.gtk_toggled.

pack-priv void
pack-priv void
pack-priv void
public int

Returns:

the index of the column
indexOf
(TableColumn
the search column
column
)

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

public int

Returns:

the index of the item
indexOf
(TableItem
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.

public boolean

Returns:

the selection state of the item at the index
isSelected
(int
the index of the item
index
)

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

pack-priv boolean
pack-priv boolean
pack-priv long
pack-priv void
propagateDraw(long
the parent container, i.e. fixedHandle
container
,
long
the cairo context provided by GTK
cairo
)

Overrides org.eclipse.swt.widgets.Composite.propagateDraw.

Propagates draw events from a parent container to its children using gtk_container_propagate_draw().

pack-priv void
pack-priv void
pack-priv void
pack-priv void
pack-priv void
public void
remove(int
the index for the item
index
)

Removes the item from the receiver at the given zero-relative index.

public void
remove(int
the start of the range
start
,
int
the end of the range
end
)

Removes the items from the receiver which are between the given zero-relative start and end indices (inclusive).

public void
remove(int[]
the array of indices of the items
indices
)

Removes the items from the receiver's list at the given zero-relative indices.

public void
removeAll()

Removes all of the items from the receiver.

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 user changes the receiver's selection.

pack-priv long
rendererGetPreferredWidthProc(long cell, long handle, long minimun_size, long natural_size)

Overrides org.eclipse.swt.widgets.Widget.rendererGetPreferredWidthProc.

pack-priv void
rendererRender(long cell, long cr, long snapshot, long widget, long background_area, long cell_area, long expose_area, long flags)

pack-priv long
rendererRenderProc(long cell, long cr, long widget, long background_area, long cell_area, long flags)

Overrides org.eclipse.swt.widgets.Widget.rendererRenderProc.

pack-priv long
rendererSnapshotProc(long cell, long snapshot, long widget, long background_area, long cell_area, long flags)

Overrides org.eclipse.swt.widgets.Widget.rendererSnapshotProc.

pack-priv void
pack-priv Point
pack-priv void
pack-priv boolean
public void
select(int
the index of the item to select
index
)

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

public void
select(int
the start of the range
start
,
int
the end of the range
end
)

Selects the items in the range specified by the given zero-relative indices in the receiver.

public void
select(int[]
the array of indices for the items to select
indices
)

Selects the items at the given zero-relative indices in the receiver.

public void
selectAll()

Selects all of the items in the receiver.

pack-priv void
selectFocusIndex(int index)

pack-priv void
sendMeasureEvent(long cell, long width, long height)

pack-priv void
sendTreeDefaultSelection()

Used to emulate DefaultSelection event.

pack-priv void
pack-priv void
pack-priv int
setBounds(int x, int y, int width, int height, boolean move, boolean resize)

Overrides org.eclipse.swt.widgets.Composite.setBounds.

public void
setColumnOrder(int[]
the new order to display the items
order
)

Sets the order that the items in the receiver should be displayed in to the given argument which is described in terms of the zero-relative ordering of when the items were added.

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

Sets the header background color to the color specified by the argument, or to the default system color if the argument is null.

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

Sets the header foreground color to the color specified by the argument, or to the default system color if the argument is null.

public void
setHeaderVisible(boolean
the new visibility state
show
)

Marks the receiver's header as visible if the argument is true, and marks it invisible otherwise.

public void
setItemCount(int
the number of items
count
)

Sets the number of items contained in the receiver.

public void
setLinesVisible(boolean
the new visibility state
show
)

Marks the receiver's lines as visible if the argument is true, and marks it invisible otherwise.

pack-priv void
setModel(long newModel)

pack-priv void
pack-priv void
pack-priv void
public void
setRedraw(boolean
the new redraw state
redraw
)

Overrides org.eclipse.swt.widgets.Control.setRedraw.

If the argument is false, causes subsequent drawing operations in the receiver to be ignored.
pack-priv void
setScrollWidth(long column, TableItem item)

public void
setSelection(int
the index of the item to select
index
)

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

public void
setSelection(int
the start index of the items to select
start
,
int
the end index of the items to select
end
)

Selects the items in the range specified by the given zero-relative indices in the receiver.

public void
setSelection(int[]
the indices of the items to select
indices
)

Selects the items at the given zero-relative indices in the receiver.

public void
setSelection(TableItem
the item to select
item
)

Sets the receiver's selection to the given item.

public void
setSelection(TableItem[]
the array of items
items
)

Sets the receiver's selection to be the given array of items.

public void
setSortColumn(TableColumn
the column used by the sort indicator or null
column
)

Sets the column used by the sort indicator for the receiver.

public void
setSortDirection(int
the direction of the sort indicator
direction
)

Sets the direction of the sort indicator for the receiver.

public void
setTopIndex(int
the index of the top item
index
)

Sets the zero-relative index of the item which is currently at the top of the receiver.

public void
showColumn(TableColumn
the column to be shown
column
)

Shows the column.

pack-priv boolean
public void
showItem(TableItem
the item to be shown
item
)

Shows the item.

pack-priv void
showItem(long iter)

public void
showSelection()

Shows the selection.

private void
pack-priv void
pack-priv void
pack-priv long
windowProc(long handle, long arg0, long user_data)

Overrides org.eclipse.swt.widgets.Control.windowProc.

Inherited from org.eclipse.swt.widgets.Composite:
_getChildren_getTabListadjustChildClippingchangedcheckBufferedcheckSubwindowcomputeTabListconnectFixedHandleDrawcreateHandledrawBackgrounddrawBackgroundInPixelsenableWidgetfindDeferredControlfindMenusfixChildrenfixClippingsfixModalfixParentGdkResourcefixStylefixTabListfixZOrderfocusHandleforceFocusgetBackgroundModegetChildrengetChildrenCountgetLayoutgetLayoutDeferredgetTabListgtk4_key_press_eventgtk_focusgtk_focus_in_eventgtk_focus_out_eventgtk_mapgtk_realizegtk_scroll_childgtk_style_updatedhasBorderhooksKeysimHandleisLayoutDeferredisTabGrouplayoutlayoutlayoutlayoutlayoutmarkLayoutminimumSizemoveAbovemoveBelowmoveChildrenmustBeVisibleOnInitBoundsparentingHandleprintWidgetredrawChildrenreleaseHandleremoveControlresizeHandlesetBackgroundModesetFocussetLayoutsetLayoutDeferredsetScrollBarVisiblesetTabGroupFocussetTabItemFocussetTabListshowWidgettoStringtranslateMnemonictranslateTraversaltraversalCodeupdateBackgroundModeupdateLayout