getting height of TableView?
Andrew Munn
andrew at nmedia.net
Wed Jun 26 17:26:44 UTC 2019
I have a question similar to this one:
https://stackoverflow.com/questions/27945817/javafx-adapt-tableview-height-to-number-of-rows
I have a table that rows are added & removed from. I want the SplitPane
holding the table to resize itself as needed.
<SplitPane fx:id="splitPane" focusTraversable="true" orientation="VERTICAL" prefHeight="-1.0" prefWidth="-1.0" VBox.vgrow="ALWAYS">
<items>
<ScrollPane fx:id="listScrollPane" fitToHeight="true" fitToWidth="true">
<content>
<TableView>
...
</TableView>
</content>
</ScrollPane>
...
When I change my table font size or add/remove rows I currently call this:
public void updateListTableHeight(){
double h = (tableData.size()+1) * 2.1 * fontSize;
Platform.runLater(() -> {
listScrollPane.setMaxHeight(h);
listScrollPane.setMinHeight(h);
});
}
This is not an ideal solution. There must be a better way to get the
correct table size (no empty space). Best would be to bind the
ScrollPane height to the TableView height.
Thanks.
More information about the openjfx-dev
mailing list