如何自动调整 JavaFX 中的 TableColumn 以适应 TableView 的大小?

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

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

我有一个 table,它只包含列 ID 和名称。但是,此 table 嵌入在 SplitPane 中,使用户有机会轻松快速地更改大小。我希望 table 始终填满整个宽度。 ID 列的大小设置为 70,只有名称列应始终传播到 table 的剩余宽度。我使用 FXML 创建我的布局。是否可以直接在 FXML 中进行设置?

好的,试试下面的:

idcolumn.prefWidthProperty().bind(table.widthProperty().multiply(0.15)); namecolumn.prefWidthProperty().bind(table.widthProperty().multiply(0.85));

假设 table 是 SplitPane 的宽度。