- All Implemented Interfaces:
EventTarget
Stage.
The main purpose of this is to wrap/show AbstractMFXDialog by
setting the contentProperty().
This stage dialog is also draggable with the mouse (can be enabled/disabled),
can be closed when pressing on the owner node (overlay close feature),
can "scrim" the owner node on open. To make these last two features work
it's necessary to specify who is the owner node, setOwnerNode(Pane).
Stage have been
overridden, however the Stage.show() method is final, to properly show the dialog
please use showDialog() instead.
A side note on usage:
Unfortunately in JavaFX there is still no concept of "low-weight" dialog.
Even the JavaFX's default implementation is just a Stage. The issue
with that is that creating Stages is a quite expensive task, cannot be done on separate
threads dor whatever reason, and therefore can make the application unresponsive,
even if for a short time.
So, the advice is to build this dialogs ahead of time, keep them in memory if you can, so that you can use them whenever you need and just change their content if needed,
-
Property Summary
PropertiesTypePropertyDescriptionSpecifies whether the dialog should be centered on thegetOwnerNode()when shown.Specifies the dialog' scene root node.Specifies whether to scrim thegetOwnerNode()when showing the dialog.Specifies the strength(opacity, so values from 0.0 to 1.0) of the scrim effect, by default it is 0.5Properties inherited from class javafx.stage.Stage
alwaysOnTop, fullScreenExitHint, fullScreenExitKey, fullScreen, iconified, maxHeight, maximized, maxWidth, minHeight, minWidth, resizable, titleProperties 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
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected ScenebuildScene(AbstractMFXDialog content) Builds the dialog's scene for the given content.protected voidThis is responsible for centering the dialog on thegetOwnerNode()(if enabled).Specifies whether the dialog should be centered on thegetOwnerNode()when shown.Specifies the dialog' scene root node.voiddispose()Disposes the dialog, making it not reusable anymore!Gets the value of the property content.doubleGets the value of the property scrimStrength.voidhide()CallsunScrimOwner()then closes the dialog.protected voidEnables/Disabled the draggable feature.protected voidEnables/Disables the overlay close feature.booleanGets the value of the property centerInOwnerNode.booleanbooleanbooleanGets the value of the property scrimOwner.static MFXStageDialogConvenience method to create aMFXStageDialogfrom an FXML file.static MFXStageDialogloadOrNull(Class<?> clazz, String fxmlPath) Same asload(Class, String), but in case of fail it will return null.protected voidThis is responsible for applying the scrim effect (if enabled) according to thegetScrimPriority().Specifies whether to scrim thegetOwnerNode()when showing the dialog.Specifies the strength(opacity, so values from 0.0 to 1.0) of the scrim effect, by default it is 0.5voidsetCenterInOwnerNode(boolean centerInOwnerNode) Sets the value of the property centerInOwnerNode.voidsetContent(AbstractMFXDialog content) Sets the value of the property content.voidsetDraggable(boolean draggable) voidsetOverlayClose(boolean overlayClose) voidsetOwnerNode(Pane ownerNode) voidsetScrimOwner(boolean scrimOwner) Sets the value of the property scrimOwner.voidsetScrimPriority(ScrimPriority scrimPriority) Sets the enum constant used to specify how to apply the scrim effect.voidsetScrimStrength(double scrimStrength) Sets the value of the property scrimStrength.voidCallsscrimOwner()then shows the dialog and waits.voidCallsscrimOwner()than shows the dialog.protected voidIfgetOwnerNode()is not null removes the scrim effect from it.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, titleProperty, toBack, toFrontMethods 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, 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
-
Property Details
-
content
Specifies the dialog' scene root node.- See Also:
-
centerInOwnerNode
Specifies whether the dialog should be centered on thegetOwnerNode()when shown. -
scrimOwner
Specifies whether to scrim thegetOwnerNode()when showing the dialog.- See Also:
-
scrimStrength
Specifies the strength(opacity, so values from 0.0 to 1.0) of the scrim effect, by default it is 0.5- See Also:
-
-
Constructor Details
-
MFXStageDialog
public MFXStageDialog() -
MFXStageDialog
-
-
Method Details
-
buildScene
Builds the dialog's scene for the given content. -
initDraggable
protected void initDraggable()Enables/Disabled the draggable feature. -
initOverlayClose
protected void initOverlayClose()Enables/Disables the overlay close feature. -
showDialog
public void showDialog()CallsscrimOwner()than shows the dialog. -
showAndWait
public void showAndWait()CallsscrimOwner()then shows the dialog and waits.- Overrides:
showAndWaitin classStage
-
hide
public void hide()CallsunScrimOwner()then closes the dialog. -
scrimOwner
protected void scrimOwner()This is responsible for applying the scrim effect (if enabled) according to thegetScrimPriority(). -
unScrimOwner
protected void unScrimOwner()IfgetOwnerNode()is not null removes the scrim effect from it. -
centerInOwner
protected void centerInOwner()This is responsible for centering the dialog on thegetOwnerNode()(if enabled). -
dispose
public void dispose()Disposes the dialog, making it not reusable anymore! -
load
Convenience method to create aMFXStageDialogfrom an FXML file.Two notes:
- the file is loaded using the given class, so make sure the FXML file is in the right directory
- the method expects to load a
AbstractMFXDialogas root- Throws:
IOException
-
loadOrNull
Same asload(Class, String), but in case of fail it will return null. -
getContent
Gets the value of the property content.- Property description:
- Specifies the dialog' scene root node.
-
contentProperty
Specifies the dialog' scene root node.- See Also:
-
setContent
Sets the value of the property content.- Property description:
- Specifies the dialog' scene root node.
-
isDraggable
public boolean isDraggable()- Returns:
- whether the dialog is draggable
-
setDraggable
public void setDraggable(boolean draggable) -
isOverlayClose
public boolean isOverlayClose()- Returns:
- whether the dialog will be closed when pressing on the specified
getOwnerNode()
-
setOverlayClose
public void setOverlayClose(boolean overlayClose) -
getOwnerNode
- Returns:
- the node which "owns" the dialog
-
setOwnerNode
-
isCenterInOwnerNode
public boolean isCenterInOwnerNode()Gets the value of the property centerInOwnerNode.- Property description:
- Specifies whether the dialog should be centered on the
getOwnerNode()when shown.
-
centerInOwnerNodeProperty
Specifies whether the dialog should be centered on thegetOwnerNode()when shown. -
setCenterInOwnerNode
public void setCenterInOwnerNode(boolean centerInOwnerNode) Sets the value of the property centerInOwnerNode.- Property description:
- Specifies whether the dialog should be centered on the
getOwnerNode()when shown.
-
isScrimOwner
public boolean isScrimOwner()Gets the value of the property scrimOwner.- Property description:
- Specifies whether to scrim the
getOwnerNode()when showing the dialog.
-
scrimOwnerProperty
Specifies whether to scrim thegetOwnerNode()when showing the dialog.- See Also:
-
setScrimOwner
public void setScrimOwner(boolean scrimOwner) Sets the value of the property scrimOwner.- Property description:
- Specifies whether to scrim the
getOwnerNode()when showing the dialog.
-
getScrimStrength
public double getScrimStrength()Gets the value of the property scrimStrength.- Property description:
- Specifies the strength(opacity, so values from 0.0 to 1.0) of the scrim effect, by default it is 0.5
-
scrimStrengthProperty
Specifies the strength(opacity, so values from 0.0 to 1.0) of the scrim effect, by default it is 0.5- See Also:
-
setScrimStrength
public void setScrimStrength(double scrimStrength) Sets the value of the property scrimStrength.- Property description:
- Specifies the strength(opacity, so values from 0.0 to 1.0) of the scrim effect, by default it is 0.5
-
getScrimPriority
- Returns:
- the enum constant used to specify how to apply the scrim effect.
You can have two owners, one is the stage owner(Window) and the other is the dialog owner(Pane).
Sometimes it's better to apply the scrim to the window (for example the owner node would not allow to apply the
scrim effect, for example AnchorPanes, VBoxes, HBoxes...), but you still want to center the dialog in the owner node.
Setting this to
ScrimPriority.WINDOWwill tell the dialog to apply the effect toStage.getOwner(), setting this toScrimPriority.NODEwill tell the dialog to apply the effect togetOwnerNode().
-
setScrimPriority
Sets the enum constant used to specify how to apply the scrim effect.- See Also:
-