Top Description Fields Constructors Methods
org.controlsfx.control.tableview2.cell

public Class TextField2TableCell<S, T>

extends TextFieldTableCell<S, T>
Class Inheritance
Type Parameters
<S>
The type of the objects contained within the TableView items list.
<T>
The type of the elements contained within the TableColumn.
Imports
javafx.beans.InvalidationListener, .Observable, javafx.event.Event, javafx.scene.control.TableCell, .TableColumn, .TablePosition, .TableView, .TextField, javafx.scene.control.cell.TextFieldTableCell, javafx.scene.input.KeyEvent, javafx.util.Callback, .StringConverter, javafx.util.converter.DefaultStringConverter

A class containing a TableCell implementation that draws a TextField node inside the cell.

By default, the TextField2TableCell is rendered as a javafx.scene.control.Label when not being edited, and as a TextField when in editing mode. The TextField will, by default, stretch to fill the entire table cell. This table cell supports commit on focus lost

Field Summary

Modifier and TypeField and Description
private TextField

Constructor Summary

AccessConstructor and Description
public
TextField2TableCell()

Creates a default TextField2TableCell with a null converter.

public
TextField2TableCell(StringConverter<T>
A converter that can convert the given String (from what the user typed in) into an instance of type T.
converter
)

Creates a TextField2TableCell that provides a TextField when put into editing mode that allows editing of the cell content.

Method Summary

Modifier and TypeMethod and Description
public void
commitEdit(T item)

Overrides javafx.scene.control.TableCell.commitEdit.

Commits an edit to the value of the cell.

public static <
The type of the objects contained within the TableView
S
>
Callback<TableColumn<S, String>, TableCell<S, String>>

Returns:

A Callback that can be inserted into the cell factory property of a TableColumn, that enables textual editing of the content.
forTableColumn
()

Hides javafx.scene.control.cell.TextFieldTableCell.forTableColumn.

Provides a TextField that allows editing of the cell content when the cell is double-clicked, or when TableView#edit(int, TableColumn) is called.

public static <
The type of the objects contained within the TableView
S
,
The type of the elements contained within the TableColumn
T
>
Callback<TableColumn<S, T>, TableCell<S, T>>

Returns:

A Callback that can be inserted into the cell factory property of a TableColumn, that enables textual editing of the content.
forTableColumn
(final StringConverter<T>
A StringConverter that can convert the given String (from what the user typed in) into an instance of type T.
converter
)

Hides javafx.scene.control.cell.TextFieldTableCell.forTableColumn.

Provides a TextField that allows editing of the cell content when the cell is double-clicked, or when TableView#edit(int, TableColumn) is called.

Inherited from javafx.scene.control.cell.TextFieldTableCell:
cancelEditconverterPropertygetConvertersetConverterstartEditupdateItem

Field Detail

textFieldback to summary
private TextField textField

Hides javafx.scene.control.cell.TextFieldTableCell.textField.

* Fields * *

Constructor Detail

TextField2TableCellback to summary
public TextField2TableCell()

Creates a default TextField2TableCell with a null converter. Without a StringConverter specified, this cell will not be able to accept input from the TextField (as it will not know how to convert this back to the domain object). It is therefore strongly encouraged to not use this constructor unless you intend to set the converter separately. This table cell supports commit on focus lost.

TextField2TableCellback to summary
public TextField2TableCell(StringConverter<T> converter)

Creates a TextField2TableCell that provides a TextField when put into editing mode that allows editing of the cell content. This method will work on any TableColumn instance, regardless of its generic type. However, to enable this, a StringConverter must be provided that will convert the given String (from what the user typed in) into an instance of type T. This item will then be passed along to the TableColumn#onEditCommitProperty() callback. This table cell supports commit on focus lost.

Parameters
converter:StringConverter<T>

A converter that can convert the given String (from what the user typed in) into an instance of type T.

Method Detail

commitEditback to summary
public void commitEdit(T item)

Overrides javafx.scene.control.TableCell.commitEdit.

Doc from javafx.scene.control.TableCell.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()));

Annotations
@Override
forTableColumnback to summary
public static <S> Callback<TableColumn<S, String>, TableCell<S, String>> forTableColumn()

Hides javafx.scene.control.cell.TextFieldTableCell.forTableColumn.

Provides a TextField that allows editing of the cell content when the cell is double-clicked, or when TableView#edit(int, TableColumn) is called. This method will only work on TableColumn instances which are of type String. This table cell supports commit on focus lost.

Parameters
<S>
The type of the objects contained within the TableView
Returns:Callback<TableColumn<S, String>, TableCell<S, String>>

A Callback that can be inserted into the cell factory property of a TableColumn, that enables textual editing of the content.

forTableColumnback to summary
public static <S, T> Callback<TableColumn<S, T>, TableCell<S, T>> forTableColumn(final StringConverter<T> converter)

Hides javafx.scene.control.cell.TextFieldTableCell.forTableColumn.

Provides a TextField that allows editing of the cell content when the cell is double-clicked, or when TableView#edit(int, TableColumn) is called. This method will work on any TableColumn instance, regardless of its generic type. However, to enable this, a StringConverter must be provided that will convert the given String (from what the user typed in) into an instance of type T. This item will then be passed along to the TableColumn#onEditCommitProperty() callback. This table cell supports commit on focus lost.

Parameters
<S>
The type of the objects contained within the TableView
<T>
The type of the elements contained within the TableColumn
converter:StringConverter<T>

A StringConverter that can convert the given String (from what the user typed in) into an instance of type T.

Returns:Callback<TableColumn<S, T>, TableCell<S, T>>

A Callback that can be inserted into the cell factory property of a TableColumn, that enables textual editing of the content.