简体   繁体   English

如何自动将JavaFX中的TableColumn调整为TableView的大小?

[英]How can I automatically adjust a TableColumn in JavaFX to the size of the TableView?

How can I automatically adjust a TableColumn in JavaFX to the size of the TableView? 如何自动将JavaFX中的TableColumn调整为TableView的大小?

I have a table which only contains the columns ID and Name. 我有一个只包含ID和Name列的表。 However, this table is embedded in a SplitPane to give the user the opportunity to change the size easily and quickly. 但是,此表嵌入在SplitPane中,使用户可以轻松快速地更改大小。 I want that the table is always filled in the whole width. 我希望表格始终填满整个宽度。 The size of the ID column is set to 70 and only the Name column should always propagate to the remaining width of the table. ID列的大小设置为70,只有Name列应始终传播到表的剩余宽度。 I use FXML to create my layout. 我使用FXML创建布局。 Is there a possibility to set this directly in the FXML? 是否可以直接在FXML中设置此设置?

OK, try with a following: 好,尝试以下方法:

idcolumn.prefWidthProperty().bind(table.widthProperty().multiply(0.15)); 。idcolumn.prefWidthProperty()结合(table.widthProperty()乘以(0.15)); namecolumn.prefWidthProperty().bind(table.widthProperty().multiply(0.85)); 。namecolumn.prefWidthProperty()结合(table.widthProperty()乘以(0.85));

assuming that table is a width of SplitPane. 假设表格是SplitPane的宽度。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM