Class AsyncTaskStage<T>
- Type Parameters:
T
- the type of the result of the asynchronous task.
- All Implemented Interfaces:
EventTarget
Stage
used to execute an asynchronous task.
The following code fragment demonstrates typical usage:
// Define callable to be executed asynchronously Callable<Integer> callable = () -> computeResult(); // Create AsyncTaskStage to execute callable with owner and cancel button AsyncTaskStage<Integer> asyncStage = new AsyncTaskStage<>(owner, true, callable); // Display AsyncTaskStage, execute and obtain result Integer result = asyncStage.showAndWaitForTaskValue();
-
Property Summary
Properties inherited from class javafx.stage.Stage
alwaysOnTop, fullScreenExitHint, fullScreenExitKey, fullScreen, iconified, maxHeight, maximized, maxWidth, minHeight, minWidth, resizable, title
Properties inherited from class javafx.stage.Window
eventDispatcher, focused, forceIntegerRenderScale, height, onCloseRequest, onHidden, onHiding, onShowing, onShown, opacity, outputScaleX, outputScaleY, renderScaleX, renderScaleY, scene, showing, width, x, y
-
Constructor Summary
ConstructorDescriptionAsyncTaskStage
(Object owner, boolean withCancel, Callable<T> callable) Creates the newAsyncTaskStage
with supplied callable.AsyncTaskStage
(Object owner, boolean withCancel, Task<T> task) Creates the newAsyncTaskStage
with supplied task. -
Method Summary
Modifier and TypeMethodDescriptionDisplays this modal stage and executes the asynchronous task.Methods inherited from class javafx.stage.Stage
alwaysOnTopProperty, close, fullScreenExitHintProperty, fullScreenExitKeyProperty, fullScreenProperty, getFullScreenExitHint, getFullScreenExitKeyCombination, getIcons, getMaxHeight, getMaxWidth, getMinHeight, getMinWidth, getModality, getOwner, getStyle, getTitle, iconifiedProperty, initModality, initOwner, initStyle, isAlwaysOnTop, isFullScreen, isIconified, isMaximized, isResizable, maxHeightProperty, maximizedProperty, maxWidthProperty, minHeightProperty, minWidthProperty, resizableProperty, setAlwaysOnTop, setFullScreen, setFullScreenExitHint, setFullScreenExitKeyCombination, setIconified, setMaxHeight, setMaximized, setMaxWidth, setMinHeight, setMinWidth, setResizable, setScene, setTitle, show, showAndWait, titleProperty, toBack, toFront
Methods inherited from class javafx.stage.Window
addEventFilter, addEventHandler, buildEventDispatchChain, centerOnScreen, eventDispatcherProperty, fireEvent, focusedProperty, forceIntegerRenderScaleProperty, getEventDispatcher, getHeight, getOnCloseRequest, getOnHidden, getOnHiding, getOnShowing, getOnShown, getOpacity, getOutputScaleX, getOutputScaleY, getProperties, getRenderScaleX, getRenderScaleY, getScene, getUserData, getWidth, getWindows, getX, getY, hasProperties, heightProperty, hide, isFocused, isForceIntegerRenderScale, isShowing, onCloseRequestProperty, onHiddenProperty, onHidingProperty, onShowingProperty, onShownProperty, opacityProperty, outputScaleXProperty, outputScaleYProperty, removeEventFilter, removeEventHandler, renderScaleXProperty, renderScaleYProperty, requestFocus, sceneProperty, setEventDispatcher, setEventHandler, setForceIntegerRenderScale, setHeight, setOnCloseRequest, setOnHidden, setOnHiding, setOnShowing, setOnShown, setOpacity, setRenderScaleX, setRenderScaleY, setUserData, setWidth, setX, setY, showingProperty, sizeToScene, widthProperty, xProperty, yProperty
-
Constructor Details
-
AsyncTaskStage
Creates the newAsyncTaskStage
with supplied callable.Argument
owner
can be aNode
, aScene
, aWindow
ornull
. Ifowner
is aNode
then"node.getScene().getWindow()"
will become the owner. Ifowner
is aScene
then"scene.getWindow()"
will become the owner. Finally, ifowner
isnull
then thisAsyncTaskStage
will become a top-level, unowned stage. See methodStage.initOwner(Window)
for more detalis.- Parameters:
owner
- the owner of this stage (can be null).withCancel
- iftrue
display a cancel button.callable
- the callable to be executed asynchronously.- Throws:
NullPointerException
- ifcallable
isnull
.
-
AsyncTaskStage
Creates the newAsyncTaskStage
with supplied task.Argument
owner
can be aNode
, aScene
, aWindow
ornull
. Ifowner
is aNode
then"node.getScene().getWindow()"
will become the owner. Ifowner
is aScene
then"scene.getWindow()"
will become the owner. Finally, ifowner
isnull
then thisAsyncTaskStage
will become a top-level, unowned stage. See methodStage.initOwner(Window)
for more detalis.- Parameters:
owner
- the owner of this stage (can be null).withCancel
- iftrue
display a cancel button.task
- the task to be executed asynchronously.- Throws:
NullPointerException
- iftask
isnull
.
-
-
Method Details
-
showAndWaitForTaskValue
Displays this modal stage and executes the asynchronous task.- Returns:
- the task result or
null
if the task was cancelled. - Throws:
Exception
- if the asynchronous task completed with error.
-