I am busy teaching myself FXML. I'm doing this by following this example.
It's a simple text editor. However, in the tutorial everything is Java code.
I myself am using FXML to seperate the view of the logic.
I currently face the following challenge:
I have defined an TextArea in my FXML like so:
<TextArea id="taTextArea" fx:id="taContent" wrapText="true" />
Usually you add action listeners using onAction="#actionName"
What I want to know is, how can I do something similar for text changes. So I can detect wether a save is needed, modify the status bar label etc.
I want to avoid having to attach the TextArea to a change listener in the init method of the controller(implementing Initializable).
Also.. when I complete this application, I will write a blog about it. With the lacking FXML documentation, I think itll be helpfull to other newbies. So I want my code to be as clean as possible.
No progress yet. I need to know if theres a thing such as code completion in FXML So I can check what kind of properties I can use in FXMl. There should be a textLength property. In the provided link the author uses lengthProperty.addListener. I need an FXML equivilant
You could use the onKeyPressed property:
onKeyPressed="#textChanged"
which calls the textChanged method in the specified controller.
For the second question: The best reference for FXML currently is the javadoc of JavaFX, since all properties are listed there.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With