[prev in list] [next in list] [prev in thread] [next in thread] 

List:       openjdk-openjfx-dev
Subject:    getting height of TableView?
From:       Andrew Munn <andrew () nmedia ! net>
Date:       2019-06-26 17:26:44
Message-ID: alpine.BSO.2.21.1906261008510.67274 () ref ! nmedia ! net
[Download RAW message or body]

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.


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic