简体   繁体   中英

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?

I have a table which only contains the columns ID and Name. However, this table is embedded in a SplitPane to give the user the opportunity to change the size easily and quickly. 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. I use FXML to create my layout. Is there a possibility to set this directly in the FXML?

OK, try with a following:

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

assuming that table is a width of SplitPane.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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