I am trying to use preferences in tornadofx . but documentation has very few about it. "unresolved references" to "preferences". From where to import preferences ? Please give and clear example.
The Preferences API in JavaFX allows you store store arbitrary configuration options in an OS dependent way. It's a direct alternative to the config
functionality in TornadoFX. This example retrieves and stores a value from the default Perferences node:
class UserEditor : View("User Editor") {
val name = SimpleStringProperty()
init {
preferences {
name.value = get("name", "Default Name")
}
}
override val root = form {
fieldset {
field("Name") {
textfield(name)
}
}
button("Save").action {
preferences {
put("name", name.value)
}
}
}
}
TornadoFX merely facilitates easier access to the Preferences store available to JavaFX applications. You can also pass a specific node name as parameter to the preferences function.