How to work with Property in JavaFX

My question

Does not work trigger an event when the value is changed, why?

import javafx.beans.property.SimpleStringProperty
import javafx.beans.property.StringProperty
import javafx.fxml.*
import javafx.scene.control.*
import java.net.*
import java.util.*

class MainController : Initializable {

    @FXML
    lateinit var nameField: TextField

    //@JvmField
    internal val name: StringProperty = SimpleStringProperty("default")

    override fun initialize(location: URL?, resources: ResourceBundle?) {

        name.addListener { _ -> println("Does not work") }

        //name.set("Alfred") // ok

        nameField.textProperty().bindBidirectional(name)
    }
}

It’s to blame, it will not work, confused.

Kotlin properties and JvavFX properties are two completely different things, one can not bind anything to them.You should use tornadofx to bring them together.

And please work on your english explanations. Yours look like you try to write haiku. There is a Russian section in kotlin slack channel.

I use the properties of Java, sorry for my English. I do not know him.

Java properties also wont work with JavaFX. You need a StringProperty object.

I use StringProperty in the example, they do not have to work the way I wanted, I made a mistake.

Sorry, missed that. In that case, everything should work just as in Java.

Thank you for your reply.