I have a fxml file:
<?xml version="1.0" encoding="UTF-8"?>
<?import javafx.scene.control.*?>
<?import javafx.scene.layout.*?>
<HBox maxHeight="-Infinity" maxWidth="-Infinity" minHeight="-Infinity" minWidth="-Infinity"
prefHeight="400.0" prefWidth="600.0" xmlns="http://javafx.com/javafx/8" xmlns:fx="http://javafx.com/fxml/1"
fx:controller="my.AppController">
<children>
<TextArea prefHeight="200.0" prefWidth="200.0" text="${ddd}"/>
</children>
</HBox>
You can see I want to use ${ddd}
to bind the text of textarea to a custom property from my.AppController
.
The code of my.AppController
:
public class AppController {
@FXML
public StringProperty ddd = new SimpleStringProperty("dddddddddd");
}
When I run this javafx application, it doesn't show anything in the textarea, seems it can't bind to the ddd
from AppController
.
What's the correct way to do it?