Views
6 months ago

tornadofx-guide

10. FXML If you want to

10. FXML If you want to test this functionality and force a different Locale , regardless which one you are currently in, override it by assigning FX.local when your App class is initialized. class MyApp: App() { override val primaryView = MyView::class } init { } FX.locale = Locale.FRENCH You should then see your Button use the French text (Figure 9.2). Figure 9.2 Internationalization with Type-Safe Builders Internationalization is not limited for use with FXML. You can also use it with type-safe builders. Set up your .properties files as specified before. But instead of using an embedded %clickToIncrement text in an FXML file, use the messages[] accessor to look up the value in the ResourceBundle . Pass this value as the text for the Button . button(messages["clickToIncrement"]) { } setOnAction { increment() } Summary 150

10. FXML FXML is helpful to know as a JavaFX developer, but it is definitely not required if you are content with TornadoFX type-safe builders and do not have any existing JavaFX applications to maintain. Type-safe builders have the benefit of using pure Kotlin, allowing you to code anything you want right within the structure declarations. FXML's benefits are primarily separation of concerns between UI and functionality, but even that can be accomplished with type-safe builders. It also can be built via drag-and-drop through the Scene Builder tool, which may be preferable for those who struggle to build UI's any other way. 151

GUIDE
Guide
GUIDE
GUIDE TO
Guide
GUIDE
Guide
GUIDE
Guide
Guide
guide
GUIDE
GUIDE
GUIDE
Guide
guide
Guide