FXML set TableView column resize policy

2019-06-22 14:26发布

How can I set a TableView's resize policy from FXML? I tired this way, but it's not working:

<TableView layoutX="20.0" layoutY="20.0" prefWidth="674.0" prefHeight="668.0" fx:id="tableView" fx:constant="CONSTRAINED_RESIZE_POLICY">
    <columns>
        <TableColumn text="First Name" />
        <TableColumn text="Last Name" />
        <TableColumn text="Email Address" />
    </columns>    
</TableView>

1条回答
何必那么认真
2楼-- · 2019-06-22 14:39

To set columnresize policy for tableview using fxml , you have to use <columnResizePolicy> tag . This will work on javafx 2.2 and later..

<TableView>
  <columnResizePolicy><TableView fx:constant="CONSTRAINED_RESIZE_POLICY"/></columnResizePolicy>
</TableView>

Reference :

Defining TableView columnResizePolicy property with fxml

查看更多
登录 后发表回答