Java FX: How to set the column constraint property using FXML


You have a Java FXML file document with a TableView and want to set the columnResizePolicy of this TableView in the fxml document.


<?xml version="1.0" encoding="UTF-8"?>

<?import java.lang.*?>
<?import java.util.*?>
<?import javafx.scene.*?>
<?import javafx.scene.control.*?>
<?import javafx.scene.layout.*?>

<AnchorPane id="AnchorPane" prefHeight="400.0" prefWidth="600.0" xmlns:fx="">
            <TableView fx:constant="CONSTRAINED_RESIZE_POLICY" />
            <TableColumn text="c1"/>
            <TableColumn text="c2"/>
            <TableColumn text="c3"/>

Don’t get confused by netbeans, which marks the line

<TableView fx:constant=”CONSTRAINED_RESIZE_POLICY” />

as an error (Constant ‘CONSTRAINED_RESIZE_POLICY’ is not defined for ‘TableView’).