Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
85 views
in Technique[技术] by (71.8m points)

java - JavaFX binding confusion

I am using an abstract class that I am not allowed to change.

The abstract class has this operation: saveButton.disableProperty().bind(validBooleanProperty.not()).

In my subclass I have @FXML private var titleTextField: TextField = _, which is a TextField that contains the title of the project.

I would like to make it so that when the titleTextField gets any sort of input, the saveButton reacts to it. I have attempted to create a listener for the titleTextField.textProperty() however I get Cannot resolve overloaded method 'addListener' error. I have no idea why it does that.

How can I bind / listen to changes in the titleTextField and make the saveButton react in this case?

question from:https://stackoverflow.com/questions/65947931/javafx-binding-confusion

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

I don't know what confused me here, the answer is pretty simple:

saveButton.disableProperty().bind(titleTextField.textProperty().isEqualTo(""))

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...