Top Description Fields Constructors Methods
javafx.scene.control

public Class TableCell<S, T>

extends IndexedCell<T>
Class Inheritance
Known Direct Subclasses
javafx.scene.control.cell.CheckBoxTableCell, javafx.scene.control.cell.ChoiceBoxTableCell, javafx.scene.control.cell.ComboBoxTableCell, javafx.scene.control.cell.ProgressBarTableCell, javafx.scene.control.cell.TextFieldTableCell
Type Parameters
<S>
The type of the TableView generic type (i.e. S == TableView<S>). This should also match with the first generic type in TableColumn.
<T>
The type of the item contained within the Cell.
Imports
javafx.css.PseudoClass, javafx.beans.InvalidationListener, .WeakInvalidationListener, javafx.beans.value.ObservableValue, javafx.collections.ListChangeListener, .WeakListChangeListener, .FXCollections, javafx.event.Event, javafx.scene.AccessibleAction, .AccessibleAttribute, .AccessibleRole, javafx.scene.control.TableView.TableViewFocusModel, .TableColumn.CellEditEvent, javafx.scene.control.skin.TableCellSkin, java.lang.ref.WeakReference, java.util.List, javafx.beans.property.ReadOnlyObjectProperty, .ReadOnlyObjectWrapper

Represents a single row/column intersection in a TableView. To represent this intersection, a TableCell contains an index property, as well as a tableColumn property. In addition, a TableCell instance knows what TableRow it exists in.

A note about selection: A TableCell visually shows it is selected when two conditions are met:

  1. The TableSelectionModel#isSelected(int, TableColumnBase) method returns true for the row / column that this cell represents, and
  2. The cell selection mode property is set to true (to represent that it is allowable to select individual cells (and not just rows of cells)).
Since
JavaFX 2.0
See Also
TableView, TableColumn, Cell, IndexedCell, TableRow

Field Summary

Modifier and TypeField and Description
private final InvalidationListener
private int
private ListChangeListener<String>
private final InvalidationListener
private ObservableValue<T>
private static final String
private TablePosition<S, T>
private final InvalidationListener
private final InvalidationListener
private boolean
private boolean
private boolean
private WeakReference<S>
private static final PseudoClass
private ListChangeListener<TablePosition<S, T>>
private ReadOnlyObjectWrapper<TableColumn<S, T>>
private ReadOnlyObjectWrapper<TableRow<S>>
tableRow

The TableRow that this TableCell currently finds itself placed within.

private final InvalidationListener
private ReadOnlyObjectWrapper<TableView<S>>
private boolean
private ListChangeListener<TableColumn<S, ?>>
private final WeakInvalidationListener
private final WeakListChangeListener<String>
private final WeakInvalidationListener
private final WeakInvalidationListener
private final WeakInvalidationListener
private final WeakListChangeListener<TablePosition<S, T>>
private final WeakInvalidationListener
private final WeakListChangeListener<TableColumn<S, ?>>

Constructor Summary

AccessConstructor and Description
public
TableCell()

Constructs a default TableCell instance with a style class of 'table-cell'

Method Summary

Modifier and TypeMethod and Description
public void
cancelEdit()

Overrides javafx.scene.control.Cell.cancelEdit.

Cancels an edit to the value of the cell.

private void
public void
commitEdit(T
the value as input by the end user, which should be persisted in the relevant way given the data source underpinning the user interface and the install edit commit handler of the UI control
newValue
)

Overrides javafx.scene.control.Cell.commitEdit.

Commits an edit to the value of the cell.

protected Skin<?>
createDefaultSkin()

Overrides javafx.scene.control.Control.createDefaultSkin.

Create a new instance of the default skin for this control.

private void
doCancelEdit()

Switches an editing cell into not editing without changing control's editing state.

public void
executeAccessibleAction(AccessibleAction
the action to execute
action
,
Object...
optional list of parameters
parameters
)

Overrides javafx.scene.control.Control.executeAccessibleAction.

This method is called by the assistive technology to request the action indicated by the argument should be executed.

pack-priv TablePosition<S, T>
public final TableColumn<S, T>
public final TableRow<S>
public final TableView<S>
pack-priv void
indexChanged(int
the old index
oldIndex
,
int
the new index
newIndex
)

Overrides javafx.scene.control.IndexedCell.indexChanged.

This method is called whenever the index is changed, regardless of whether the new index is the same as the old index.

private boolean
protected void
layoutChildren()

Overrides javafx.scene.control.Cell.layoutChildren.

Invoked during the layout pass to layout the children in this Parent.

private boolean
match(TablePosition<S, ?> pos)

private void
possiblySetId(String idCandidate)

private void
possiblySetStyle(String styleCandidate)

public Object
queryAccessibleAttribute(AccessibleAttribute
the requested attribute
attribute
,
Object...
optional list of parameters
parameters
)

Overrides javafx.scene.control.Control.queryAccessibleAttribute.

This method is called by the assistive technology to request the value for an attribute.

private void
private void
private void
public void
startEdit()

Overrides javafx.scene.control.Cell.startEdit.

Starts an edit to the value of the cell.

public final ReadOnlyObjectProperty<TableColumn<S, T>>

Returns:

the TableColumn instance that backs this TableCell
tableColumnProperty
()

The TableColumn instance that backs this TableCell.

public final ReadOnlyObjectProperty<TableRow<S>>
public final ReadOnlyObjectProperty<TableView<S>>

Returns:

the TableView associated with this TableCell
tableViewProperty
()

The TableView associated with this TableCell.

private ReadOnlyObjectWrapper<TableView<S>>
private void
private void
private void
private void
updateItem(int oldIndex)

public void
updateSelected(boolean
whether or not to select this cell.
selected
)

Overrides javafx.scene.control.Cell.updateSelected.

Updates whether this cell is in a selected state or not.

private void
public final void
updateTableColumn(TableColumn<S, T>
the TableColumn associated with this TableCell
col
)

Updates the TableColumn associated with this TableCell.

public final void
updateTableRow(TableRow<T>
the TableRow associated with this TableCell
tableRow
)

Updates the TableRow associated with this TableCell.

public final void
updateTableView(TableView<S>
the TableView associated with this TableCell
tv
)

Updates the TableView associated with this TableCell.

Inherited from javafx.scene.control.IndexedCell:
getIndexindexPropertyupdateIndex

Field Detail

columnIdListenerback to summary
private final InvalidationListener columnIdListener
columnIndexback to summary
private int columnIndex
columnStyleClassListenerback to summary
private ListChangeListener<String> columnStyleClassListener
columnStyleListenerback to summary
private final InvalidationListener columnStyleListener
currentObservableValueback to summary
private ObservableValue<T> currentObservableValue
DEFAULT_STYLE_CLASSback to summary
private static final String DEFAULT_STYLE_CLASS

Hides javafx.scene.control.IndexedCell.DEFAULT_STYLE_CLASS.

editingCellAtStartEditback to summary
private TablePosition<S, T> editingCellAtStartEdit
editingListenerback to summary
private final InvalidationListener editingListener
focusedListenerback to summary
private final InvalidationListener focusedListener
isFirstRunback to summary
private boolean isFirstRun
isLastVisibleColumnback to summary
private boolean isLastVisibleColumn
itemDirtyback to summary
private boolean itemDirty

Hides javafx.scene.control.Cell.itemDirty.

oldRowItemRefback to summary
private WeakReference<S> oldRowItemRef
PSEUDO_CLASS_LAST_VISIBLEback to summary
private static final PseudoClass PSEUDO_CLASS_LAST_VISIBLE
selectedListenerback to summary
private ListChangeListener<TablePosition<S, T>> selectedListener
tableColumnback to summary
private ReadOnlyObjectWrapper<TableColumn<S, T>> tableColumn
tableRowback to summary
private ReadOnlyObjectWrapper<TableRow<S>> tableRow

The TableRow that this TableCell currently finds itself placed within. The TableRow may be null early in the TableCell lifecycle, in the period between the TableCell being instantiated and being set into an owner TableRow.

tableRowUpdateObserverback to summary
private final InvalidationListener tableRowUpdateObserver
tableViewback to summary
private ReadOnlyObjectWrapper<TableView<S>> tableView
updateEditingIndexback to summary
private boolean updateEditingIndex
visibleLeafColumnsListenerback to summary
private ListChangeListener<TableColumn<S, ?>> visibleLeafColumnsListener
weakColumnIdListenerback to summary
private final WeakInvalidationListener weakColumnIdListener
weakColumnStyleClassListenerback to summary
private final WeakListChangeListener<String> weakColumnStyleClassListener
weakColumnStyleListenerback to summary
private final WeakInvalidationListener weakColumnStyleListener
weakEditingListenerback to summary
private final WeakInvalidationListener weakEditingListener
weakFocusedListenerback to summary
private final WeakInvalidationListener weakFocusedListener
weakSelectedListenerback to summary
private final WeakListChangeListener<TablePosition<S, T>> weakSelectedListener
weaktableRowUpdateObserverback to summary
private final WeakInvalidationListener weaktableRowUpdateObserver
weakVisibleLeafColumnsListenerback to summary
private final WeakListChangeListener<TableColumn<S, ?>> weakVisibleLeafColumnsListener

Constructor Detail

TableCellback to summary
public TableCell()

Constructs a default TableCell instance with a style class of 'table-cell'

Method Detail

cancelEditback to summary
public void cancelEdit()

Overrides javafx.scene.control.Cell.cancelEdit.

Doc from javafx.scene.control.Cell.cancelEdit.

Cancels an edit to the value of the cell. Call this function to transition from an editing state into a non-editing state, without saving any user input.

Annotations
@Override
cleanUpTableViewListenersback to summary
private void cleanUpTableViewListeners(TableView<S> tableView)
commitEditback to summary
public void commitEdit(T newValue)

Overrides javafx.scene.control.Cell.commitEdit.

Doc from javafx.scene.control.Cell.commitEdit.

Commits an edit to the value of the cell. Call this function when appropriate (based on the user interaction requirements of your cell editing user interface) to do two things:

  1. Fire the appropriate events back to the backing UI control (e.g., ListView). This will begin the process of pushing this edit back to the relevant data source / property (although it does not guarantee that this will be successful - that is dependent upon the specific edit commit handler being used). Refer to the UI control class javadoc for more detail.
  2. Begin the transition from an editing state into a non-editing state.

In general there is no need to override this method in custom cell implementations - it should be sufficient to simply call this method when appropriate (e.g., when the user pressed the Enter key, you may do something like cell.commitEdit(converter.fromString(textField.getText()));

Parameters
newValue:T

the value as input by the end user, which should be persisted in the relevant way given the data source underpinning the user interface and the install edit commit handler of the UI control

Annotations
@Override
createDefaultSkinback to summary
protected Skin<?> createDefaultSkin()

Overrides javafx.scene.control.Control.createDefaultSkin.

Doc from javafx.scene.control.Control.createDefaultSkin.

Create a new instance of the default skin for this control. This is called to create a skin for the control if no skin is provided via CSS -fx-skin or set explicitly in a sub-class with setSkin(...).

Returns:Skin<?>

new instance of default skin for this control. If null then the control will have no skin unless one is provided by css.

Annotations
@Override
doCancelEditback to summary
private void doCancelEdit()

Switches an editing cell into not editing without changing control's editing state.

executeAccessibleActionback to summary
public void executeAccessibleAction(AccessibleAction action, Object... parameters)

Overrides javafx.scene.control.Control.executeAccessibleAction.

Doc from javafx.scene.control.Control.executeAccessibleAction.

This method is called by the assistive technology to request the action indicated by the argument should be executed.

This method is commonly overridden by subclasses to implement action that are required for a specific role.
If a particular action is not handled, the superclass implementation must be called.

Parameters
action:AccessibleAction

Doc from javafx.scene.Node.executeAccessibleAction.

the action to execute

parameters:Object[]

Doc from javafx.scene.Node.executeAccessibleAction.

optional list of parameters

Annotations
@Override
getEditingCellAtStartEditback to summary
pack-priv TablePosition<S, T> getEditingCellAtStartEdit()
getTableColumnback to summary
public final TableColumn<S, T> getTableColumn()
getTableRowback to summary
public final TableRow<S> getTableRow()
getTableViewback to summary
public final TableView<S> getTableView()
indexChangedback to summary
pack-priv void indexChanged(int oldIndex, int newIndex)

Overrides javafx.scene.control.IndexedCell.indexChanged.

Doc from javafx.scene.control.IndexedCell.indexChanged.

This method is called whenever the index is changed, regardless of whether the new index is the same as the old index.

Parameters
oldIndex:int

the old index

newIndex:int

the new index

Annotations
@Override
isInCellSelectionModeback to summary
private boolean isInCellSelectionMode()
layoutChildrenback to summary
protected void layoutChildren()

Overrides javafx.scene.control.Cell.layoutChildren.

Doc from javafx.scene.control.Cell.layoutChildren.

Invoked during the layout pass to layout the children in this Parent. By default it will only set the size of managed, resizable content to their preferred sizes and does not do any node positioning.

Subclasses should override this function to layout content as needed.

Annotations
@Override
matchback to summary
private boolean match(TablePosition<S, ?> pos)
possiblySetIdback to summary
private void possiblySetId(String idCandidate)
possiblySetStyleback to summary
private void possiblySetStyle(String styleCandidate)
queryAccessibleAttributeback to summary
public Object queryAccessibleAttribute(AccessibleAttribute attribute, Object... parameters)

Overrides javafx.scene.control.Control.queryAccessibleAttribute.

Doc from javafx.scene.control.Control.queryAccessibleAttribute.

This method is called by the assistive technology to request the value for an attribute.

This method is commonly overridden by subclasses to implement attributes that are required for a specific role.
If a particular attribute is not handled, the superclass implementation must be called.

Parameters
attribute:AccessibleAttribute

Doc from javafx.scene.Node.queryAccessibleAttribute.

the requested attribute

parameters:Object[]

Doc from javafx.scene.Node.queryAccessibleAttribute.

optional list of parameters

Returns:Object

Doc from javafx.scene.Node.queryAccessibleAttribute.

the value for the requested attribute

Annotations
@Override
setTableColumnback to summary
private void setTableColumn(TableColumn<S, T> value)
setTableRowback to summary
private void setTableRow(TableRow<S> value)
setTableViewback to summary
private void setTableView(TableView<S> value)
startEditback to summary
public void startEdit()

Overrides javafx.scene.control.Cell.startEdit.

Doc from javafx.scene.control.Cell.startEdit.

Starts an edit to the value of the cell. Call this function to transition from a non-editing state into an editing state, if the cell is editable. If this cell is already in an editing state, it will stay in it.

Annotations
@Override
tableColumnPropertyback to summary
public final ReadOnlyObjectProperty<TableColumn<S, T>> tableColumnProperty()

The TableColumn instance that backs this TableCell.

Returns:ReadOnlyObjectProperty<TableColumn<S, T>>

the TableColumn instance that backs this TableCell

tableRowPropertyback to summary
public final ReadOnlyObjectProperty<TableRow<S>> tableRowProperty()
tableViewPropertyback to summary
public final ReadOnlyObjectProperty<TableView<S>> tableViewProperty()

The TableView associated with this TableCell.

Returns:ReadOnlyObjectProperty<TableView<S>>

the TableView associated with this TableCell

tableViewPropertyImplback to summary
private ReadOnlyObjectWrapper<TableView<S>> tableViewPropertyImpl()
updateColumnIndexback to summary
private void updateColumnIndex()
updateEditingback to summary
private void updateEditing()
updateFocusback to summary
private void updateFocus()
updateItemback to summary
private void updateItem(int oldIndex)
updateSelectedback to summary
public void updateSelected(boolean selected)

Overrides javafx.scene.control.Cell.updateSelected.

Doc from javafx.scene.control.Cell.updateSelected.

Updates whether this cell is in a selected state or not.

Parameters
selected:boolean

whether or not to select this cell.

Annotations
@Override
updateSelectionback to summary
private void updateSelection()
updateTableColumnback to summary
public final void updateTableColumn(TableColumn<S, T> col)

Updates the TableColumn associated with this TableCell.

Note

This function is intended to be used by experts, primarily by those implementing new Skins. It is not common for developers or designers to access this function directly.

Parameters
col:TableColumn<S, T>

the TableColumn associated with this TableCell

updateTableRowback to summary
public final void updateTableRow(TableRow<T> tableRow)

Updates the TableRow associated with this TableCell.

Note

This function is intended to be used by experts, primarily by those implementing new Skins. It is not common for developers or designers to access this function directly.

Parameters
tableRow:TableRow<T>

the TableRow associated with this TableCell

updateTableViewback to summary
public final void updateTableView(TableView<S> tv)

Updates the TableView associated with this TableCell. This is typically only done once when the TableCell is first added to the TableView.

Note

This function is intended to be used by experts, primarily by those implementing new Skins. It is not common for developers or designers to access this function directly.

Parameters
tv:TableView<S>

the TableView associated with this TableCell