You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Additions to ScalaFX that do not have corresponding concepts in JavaFX. The key parts are helper methods in `org.scalafx.extras` and support for a working with Model-View and FXML.
The latest published ScalaFX Extras version: [](https://maven-badges.herokuapp.com/maven-central/org.scalafx/scalafx-extras_2.12)
46
+
47
+
Features
48
+
--------
49
+
50
+
### Helper Methods
51
+
52
+
Package `org.scalafx.extras` contains basic helper methods for running tasks on threads and showing exception messages.
53
+
The main helper methods:
54
+
55
+
*`onFX` run code on FX Application thread in parallel
56
+
*`onFXAndWait` run code on FX Application thread and wait till finished
57
+
*`offFX` run code a thread in parallel
58
+
*`offFXAndWait` run code a thread and wait till finished
59
+
*`showException` show an exception dialog
60
+
61
+
Example scheduling some code on FX Application thread
62
+
```scala
63
+
onFX {
64
+
counterService.doResume()
65
+
_running.value =true
66
+
}
67
+
68
+
```
69
+
70
+
Example execution some code on a separate thread and waiting for the result of computation
71
+
```scala
72
+
valx= offFXAndWait {
73
+
vala=3
74
+
valb=7
75
+
a * b
76
+
}
77
+
78
+
```
79
+
80
+
### Simpler Display of Dialogs
81
+
82
+
The mixin `ShowMessage` makes it easier to display dialogs. It is typically used with a UI `Model`.
83
+
The dialogs can be displayed using a single method, like `showInformation`, `showConfirmation`. `ShowMessage` takes care of blocking parent windows and using parent icons in dialogs. It can also log warnings, errors, and exceptions when warnings, errors, and exceptions dialogs are displayed.
84
+
85
+
```scala
86
+
classMyUIModelextendsModelwithShowMessage {
87
+
88
+
defonSomeUserAction():Unit= {
89
+
// ...
90
+
showInformation("Dialog Title",
91
+
"This is the information \"header\"",
92
+
"This is the information detailed \"content\".")
93
+
// ...
94
+
}
95
+
96
+
// ...
97
+
}
98
+
```
99
+
The demos module has a complete example of an simple application in `ShowMessageDemoApp`.
100
+
101
+
### BusyWorker
102
+
103
+
BusyWorker helps running UI tasks a separate threads (other than the JavaFX Application thread).
104
+
It will show busy cursor and disable specified nodes while task is performed.
105
+
It gives an option to show progress and status messages.
106
+
`BusyWorker` run tasks and takes care of handling handling exceptions and displaying error dialogs.
107
+
There is also option to perform custom finish actions after task is completed.
108
+
109
+
A simple case of using `BusyWorker`.
110
+
When the task is running, it will disable the root pane of the `parentWindow` to indicate that a task is performed.
111
+
It will also change the cursor in the root pane to busy.
112
+
When task is done, the cursor will be changed back to default and root pane will enabled back.
0 commit comments