samedi 27 décembre 2014

Set CheckBoxTableCell in FXML

I currently have a problem with setting a CheckBoxTableCell from the FXML. I tried to convert this code to FXML:



tableCol.setCellValueFactory(new PropertyValueFactory<Product, Boolean>("property"));
tableCol.setCellFactory(CheckBoxTableCell.forTableColumn(toStockCol));


where 'property' is just some attribute of the 'Product' Class (from type 'boolean'). This code works fine. I now try to set this in the FXML, like this:



<TableColumn text="Some Col">
<cellValueFactory><PropertyValueFactory property="property" /></cellValueFactory>
<cellFactory><CheckBoxTableCell editable="true" /></cellFactory>
</TableColumn>


This doesn't work, I get the following error (which is a FXML LoadExeption):



Caused by: java.lang.IllegalArgumentException: Unable to coerce CheckBoxTableCell@24d62d1e[styleClass=cell indexed-cell table-cell check-box-table-cell]'null' to interface javafx.util.Callback.
at com.sun.javafx.fxml.BeanAdapter.coerce(BeanAdapter.java:495)
at com.sun.javafx.fxml.BeanAdapter.put(BeanAdapter.java:258)
at com.sun.javafx.fxml.BeanAdapter.put(BeanAdapter.java:54)
at javafx.fxml.FXMLLoader$PropertyElement.set(FXMLLoader.java:1409)
at javafx.fxml.FXMLLoader$ValueElement.processEndElement(FXMLLoader.java:786)
at javafx.fxml.FXMLLoader.processEndElement(FXMLLoader.java:2827)
at javafx.fxml.FXMLLoader.loadImpl(FXMLLoader.java:2536)
... 42 more


I can not figure out what I am doing wrong. Also, in my opinion there is little to none documentation about how to set a CheckBox in a TableView with FXML.


Note: I would like to set this from the FXML, because it seems to be the spot for this. I know this can be done with the FXML controller. Also, I am just curious.


Any help is greatly appreciated!





Aucun commentaire:

Enregistrer un commentaire