Is it possible to make FXML property bindings (disable="${myNode.disable}"
to bind the disable property with myNode
's disabled value) from within scene builder itself?
The only way I could get it done was by manually editing the output file. Here's an example:
<?xml version="1.0" encoding="UTF-8"?>
<?import javafx.geometry.Insets?>
<?import javafx.scene.control.CheckBox?>
<?import javafx.scene.control.TextField?>
<?import javafx.scene.layout.VBox?>
<VBox spacing="10.0" xmlns="http://javafx.com/javafx/9.0.1" xmlns:fx="http://javafx.com/fxml/1">
<children>
<TextField disable="${checkbox.selected}"/>
<CheckBox fx:id="checkbox" mnemonicParsing="false" text="Disable Field" />
</children>
<opaqueInsets>
<Insets />
</opaqueInsets>
<padding>
<Insets bottom="10.0" left="10.0" right="10.0" top="10.0" />
</padding>
</VBox>
And loaded:
import javafx.application.Application;
import javafx.fxml.FXMLLoader;
import javafx.scene.Scene;
import javafx.scene.layout.VBox;
import javafx.stage.Stage;
public class App extends Application {
@Override
public void start(Stage primaryStage) throws Exception {
VBox parent = FXMLLoader.load(getClass().getResource("FxmlBindingTest.fxml"));
Scene scene = new Scene(parent);
primaryStage.setScene(scene);
primaryStage.show();
}
public static void main(String[] args) {
launch(args);
}
}
When I load back this file to scene builder, there's a yellow caution icon over that node:
What's really interesting, if I load a preview from scene builder, the values are not bound.
Scene builder will not overwrite or remove the binding text on any change, other than a change on that property itself - as expected.