I know that it is possible to create a column in TableView filled with buttons thanks to jewelsea.
我知道,由于jewelsea,可以在TableView中创建一个充满按钮的列。
But I want to know if it's possible to define it directly in the FXML.
但我想知道是否可以直接在FXML中定义它。
As an example, with other types one do:
例如,与其他类型的一个做:
Class Person:
班级人员:
private final SimpleStringProperty birthDate = new SimpleStringProperty("");
Then in the FXML:
那么在FXML中:
<TableView fx:id="table" layoutY="50.0" prefHeight="350.0" prefWidth="600.0">
<columns>
<TableColumn prefWidth="79.5" text="date of birth">
<cellValueFactory>
<PropertyValueFactory property="birthDate" />
</cellValueFactory>
</TableColumn>
</columns>
</TableView>
And one can add this element with:
并且可以添加以下元素:
@FXML private TableView<Person> table;
//...
table.getItems().add("12/02/1452");
How to achieve the same with Buttons?
如何用Buttons实现同样的目标?
1 个解决方案
#1
-1
It's not possible to add buttons to table column in FXML since cell factory is required.
由于需要单元工厂,因此无法在FXML中向表列添加按钮。
You can do it with Java code as you jewelsea did.
您可以像jewelsea那样使用Java代码来完成它。
#1
-1
It's not possible to add buttons to table column in FXML since cell factory is required.
由于需要单元工厂,因此无法在FXML中向表列添加按钮。
You can do it with Java code as you jewelsea did.
您可以像jewelsea那样使用Java代码来完成它。