Skip to Main Content

Java SE (Java Platform, Standard Edition)

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

JavaFX 2 TextArea define onChange listener in FXML

952715Jul 30 2012 — edited Jul 30 2012
Greetings,

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.(isDirty property or something alike)

I want to avoid having to attach the TextArea to a change listener in the init method of the controller(implementing Initializable).
I'm mainly worried that if this isn't possible, what would be the point of being able to define events in FXML at all.

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.

I have also posted it on stack overflow:

[link to stackoverflow|http://stackoverflow.com/questions/11716977/javafx-2-define-onchange-listener-in-fxml]

Edited by: 949712 on 30-jul-2012 1:30
This post has been answered by 948409 on Jul 30 2012
Jump to Answer
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Aug 27 2012
Added on Jul 30 2012
6 comments
1,685 views