Arno
Arno

Reputation: 1

JAVAFX : TextFieldTreeTableCell in FXML

For a TreeTableColumn, does an equivalent of the following exist in FXML?

nameColumn.setCellFactory(TextFieldTreeTableCell.forTreeTableColumn())

Something like :

<TreeTableColumn>
  <cellFactory>
    <TextFieldTreeTableCell></TextFieldTreeTableCell> -> this doesn't work
  </cellFactory>
</TreeTableColumn>

Upvotes: 0

Views: 97

Answers (1)

Slaw
Slaw

Reputation: 45806

For the no-argument TextFieldTreeTableView#forTreeTableColumn() method you can use fx:factory:

The fx:factory attribute is another means of creating objects whose classes do not have a default constructor. The value of the attribute is the name of a static, no-arg factory method for producing class instances.

For example:

<TreeTableColumn>
  <cellFactory>
    <TextFieldTreeTableCell fx:factory="forTreeTableColumn"/>
  </cellFactory>
</TreeTableColumn>

However, this won't work if you want to use the overload which accepts a StringConverter argument.

Upvotes: 1

Related Questions