package extras
- Alphabetic
- By Inheritance
- extras
- AnyRef
- Any
- Hide All
- Show All
- Public
- All
Type Members
-
class
BusyWorker extends ShowMessage
BusyWorker helps running UI tasks a separate threads (other than the JavaFX Application thread).
BusyWorker helps running UI tasks a separate threads (other than the JavaFX Application thread). It will show busy cursor and disable specified nodes while task is performed. It gives an option to show progress and status messages.
BusyWorker
run tasks and takes care of handling handling exceptions and displaying error dialogs. There is also option to perform custom finish actions after task is completed.While task is performed property
busy
is set to true. Only one task, for a given worker, can be run at the time. When a task in being performedbusyDisabledNode
will be disabled and its cursor will be set toWait
/Busy
cursor.Progress and messages from the running task can be monitored using
progressValue
andprogressMessage
properties.Below is an example of using using BusyWorker that updates a progress message and progress indicator. The full example can be found in the
BusyWorkerDemo
of the ScalaFX Extras Demo project.val buttonPane: Pane = ... val progressLabel: Label = ... val progressBar: ProgressBar = ... val busyWorker = new BusyWorker("BusyWorker Demo", buttonPane) { progressLabel.text <== progressMessage progressBar.progress <== progressValue } val button = new Button("Click Me") { onAction = () => busyWorker.doTask("Task 1")( new SimpleTask[String] { override def call(): String = { val maxItems = 10 for (i <- 1 to maxItems) { println(i) message() = s"Processing item $i/$maxItems" progress() = (i - 1) / 10.0 Thread.sleep(250) } progress() = 1 "Done" } } ) }
-
trait
ShowMessage extends AnyRef
Mixin that adds ability to easily show message dialogs.
Mixin that adds ability to easily show message dialogs. A messageLogger can be provided, so when the error or warning dialogs are shown, they are also logged.
A ShowMessage mixin will typically be used with the ModelFX.
-
trait
ShowMessageLogger extends AnyRef
Logging operations used by ShowMessage.
Logging operations used by ShowMessage. Enables ShowMessage to use loggers preferred by the user.
Value Members
-
def
initFX(): Unit
Attempt to initialize JavaFX Toolkit.
Attempt to initialize JavaFX Toolkit. This is only needed when application is not started by
JFXApp3
or JavaFXApplication
.When JavaFX toolkit is not initialized and you attempt to use JavaFX components you will get exception:
java.lang.IllegalStateException: Toolkit not initialized
.In JavaFX 9 and newer you can use
Platform.startup(() -> {})
. -
def
offFX[R](op: ⇒ R): Unit
Runs an operation
op
on a separate thread.Runs an operation
op
on a separate thread. Exceptions during execution are ignored. Similar to org.scalafx.extras#run, with default name for the thread: "offFX".- op
operation to be performed.
-
def
offFXAndWait[R](op: ⇒ R): R
Run operation
op
off FX application thread and wait for completion.Run operation
op
off FX application thread and wait for completion. If the current thread is not the FX application, the operation will be run on it (no new thread will ne created).- op
operation to be performed.
- Exceptions thrown
java.lang.InterruptedException
- if the current thread was interrupted while waitingjava.util.concurrent.CancellationException
- if the computation was cancelledjava.util.concurrent.ExecutionException
- if the computation threw an exception
-
def
onFX[R](op: ⇒ R): Unit
Run operation
op
on FX application thread.Run operation
op
on FX application thread. If on FX Application thread it will wait for operation to compete, if not on FX Application thread it will return without waiting for the operation to complete.- op
operation to be performed.
-
def
onFXAndWait[R](op: ⇒ R): R
Run operation
op
on FX application thread and wait for completion.Run operation
op
on FX application thread and wait for completion. If the current thread is the FX application, the operation will be run on it.- op
operation to be performed.
- Exceptions thrown
java.lang.InterruptedException
- if the current thread was interrupted while waitingjava.util.concurrent.CancellationException
- if the computation was cancelledjava.util.concurrent.ExecutionException
- if the computation threw an exception
-
def
run[R](op: ⇒ R, name: String): Unit
Runs an operation
op
on a separate thread.Runs an operation
op
on a separate thread. Exceptions during execution are ignored.- op
operation to run
- name
name for the thread to run the operation. Useful for debugging.
-
def
runTask[T](task: Task[T], name: String): Unit
Run task on a named daemon thread.
Run task on a named daemon thread.
- task
to run
- name
name for the thread to run the operation. Useful for debugging.
-
def
showException(title: String, message: String, t: Throwable, ownerWindow: Option[Window] = None): Unit
Show a modal dialog with an expandable details about an exception (stack trace).
Show a modal dialog with an expandable details about an exception (stack trace).
- title
dialog title
- message
message shown in the dialog header.
- t
exception.
- ownerWindow
owner window that will be blacked by the dialog.
-
def
showException(title: String, message: String, t: Throwable, ownerWindow: Window): Unit
Show a modal dialog with an expandable details about an exception (stack trace).
Show a modal dialog with an expandable details about an exception (stack trace).
- title
dialog title
- message
message shown in the dialog header.
- t
exception.
- ownerWindow
owner window that will be blacked by the dialog. Can be
null
to match JavaFX convention.
-
def
showException(title: String, message: String, t: Throwable, ownerWindow: Node): Unit
Show a modal dialog with an expandable details about an exception (stack trace).
Show a modal dialog with an expandable details about an exception (stack trace).
- title
dialog title
- message
message shown in the dialog header.
- t
exception.
- ownerWindow
owner window that will be blacked by the dialog. Can be
null
.
- object BusyWorker
Helper methods and classes to simplify ScalaFX use.
Package
org.scalafx.extras
contains basic helper methods for running tasks on threads and showing messages.Package
org.scalafx.extras.image
contains image display component with scrolling and zooming.Package
org.scalafx.extras.mvcfx
contains classes for creating with UI components based on FXML.