Views
8 months ago

tornadofx-guide

EventBus class MyView :

EventBus class MyView : View() { override val root = stackpane { paddingAll = 100 button("Fire!").action { fire(MyEvent) } } init { subscribe { alert(INFORMATION, "Event received!", "This message should only appear onc e.") unsubscribe() } } } 224

Workspaces Workspaces Java Business applications have traditionally been based on one of the Rich Client Frameworks, namely the NetBeans Platform or Eclipse RCP. An important reason for choosing an RCP platform has been the workspace-like functionality they provide. Some important features of a workspace are: Common action buttons that tie to the state of the docked view (Save, Refresh, etc) Context-based UI nodes added to the common workspace interface Navigation stack for traversing visited views, controlled through back and forward buttons like a web browser Menu system with dynamic contributions and modifications TornadoFX has begun to bridge the gap between the RCP platforms by providing Workspaces. While still in its infancy, the default functionality is a solid foundation for business applications in need of the features discussed above. A Simple Workspace Example To kick off a Workspace app, all you need to do is to subclass App and set the primary View to Workspace::class . The result can be seen below (Figure 16.1): class MyApp : App(Workspace::class) Figure 16.1 225

GUIDE
GUIDE
GUIDE
Guide
GUIDE
Guide
GUIDE
GUIDE
Guide
GUIDE
Guide
Guide
GUIDE
GUIDE
GUIDE