Class FXMLDialogWrapper<ReturnType,Controller extends javafx.fxml.Initializable>
- java.lang.Object
-
- com.jgcomptech.tools.dialogs.FXMLDialogWrapper<ReturnType,Controller>
-
- Type Parameters:
ReturnType
- the class type to be returned when the dialog is closed.Controller
- the controller class to be used for the dialog.
public final class FXMLDialogWrapper<ReturnType,Controller extends javafx.fxml.Initializable> extends java.lang.Object
Loads a dialog using the specified JavaFX fxml file.- Since:
- 1.3.1
-
-
Constructor Summary
Constructors Constructor Description FXMLDialogWrapper(java.lang.String fxmlPath)
Creates an instance of a dialog and sets the specified fxml file path.FXMLDialogWrapper(java.lang.String title, java.lang.String fxmlPath)
Creates an instance of a dialog and sets the specified title and fxml file path.FXMLDialogWrapper(java.lang.String title, javafx.scene.image.Image icon, java.lang.String fxmlPath)
Creates an instance of a dialog and sets the specified title, icon and fxml file path.FXMLDialogWrapper(java.lang.String title, javafx.scene.image.Image icon, javafx.stage.Stage owner, java.lang.String fxmlPath)
Creates an instance of a dialog and sets the specified title, icon, owner and fxml file path.FXMLDialogWrapper(java.lang.String title, javafx.stage.Stage owner, java.lang.String fxmlPath)
Creates an instance of a dialog and sets the specified title, owner and fxml file path.FXMLDialogWrapper(javafx.scene.image.Image icon, java.lang.String fxmlPath)
Creates an instance of a dialog and sets the specified icon and fxml file path.FXMLDialogWrapper(javafx.scene.image.Image icon, javafx.stage.Stage owner, java.lang.String fxmlPath)
Creates an instance of a dialog and sets the specified icon, owner and fxml file path.FXMLDialogWrapper(javafx.stage.Stage owner, java.lang.String fxmlPath)
Creates an instance of a dialog and sets the specified owner and fxml file path.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
equals(java.lang.Object o)
Controller
getController()
Returns the controller associated with theDialog
.void
getController(javafx.fxml.Initializable controller)
Defines the controller associated with theDialog
.javafx.scene.control.Dialog<ReturnType>
getDialog()
Returns theDialog
as aDialog
object.javafx.scene.image.Image
getIcon()
Returns the icon image for theDialog
that is used in the window decorations and when minimized.javafx.fxml.FXMLLoader
getLoader()
Returns theFXMLLoader
that was used to load theDialog
.javafx.stage.Stage
getOwner()
Returns the owner Window for thisDialog
, or null for a top-level, unowned stage.java.lang.String
getTitle()
Returns the title of theDialog
.int
hashCode()
boolean
isAlwaysOnTop()
Returns whether thisDialog
is kept on top of other windows.void
setAlwaysOnTop(boolean value)
Defines whether thisDialog
is kept on top of other windows.void
setIcon(javafx.scene.image.Image value)
Defines the icon image for theDialog
to be used in the window decorations and when minimized.void
setOwner(javafx.stage.Stage value)
Defines the owner Window for thisDialog
, or null for a top-level, unowned stage.void
setTitle(java.lang.String value)
Defines the title of theDialog
.java.util.Optional<ReturnType>
showAndWait()
Shows the dialog and waits for the user response (in other words, brings up a blocking dialog, with the returned value the users input).java.lang.String
toString()
-
-
-
Constructor Detail
-
FXMLDialogWrapper
public FXMLDialogWrapper(java.lang.String fxmlPath) throws java.io.IOException
Creates an instance of a dialog and sets the specified fxml file path.- Parameters:
fxmlPath
- the path of the fxml file- Throws:
java.io.IOException
- if fxml file fails to load
-
FXMLDialogWrapper
public FXMLDialogWrapper(java.lang.String title, java.lang.String fxmlPath) throws java.io.IOException
Creates an instance of a dialog and sets the specified title and fxml file path.- Parameters:
title
- the titlefxmlPath
- the path of the fxml file- Throws:
java.io.IOException
- if fxml file fails to load
-
FXMLDialogWrapper
public FXMLDialogWrapper(javafx.scene.image.Image icon, java.lang.String fxmlPath) throws java.io.IOException
Creates an instance of a dialog and sets the specified icon and fxml file path.- Parameters:
icon
- the icon image for the to be used in the window decorations and when minimizedfxmlPath
- the path of the fxml file- Throws:
java.io.IOException
- if fxml file fails to load
-
FXMLDialogWrapper
public FXMLDialogWrapper(javafx.stage.Stage owner, java.lang.String fxmlPath) throws java.io.IOException
Creates an instance of a dialog and sets the specified owner and fxml file path.- Parameters:
owner
- the owner WindowfxmlPath
- the path of the fxml file- Throws:
java.io.IOException
- if fxml file fails to load
-
FXMLDialogWrapper
public FXMLDialogWrapper(javafx.scene.image.Image icon, javafx.stage.Stage owner, java.lang.String fxmlPath) throws java.io.IOException
Creates an instance of a dialog and sets the specified icon, owner and fxml file path.- Parameters:
icon
- the icon image for the to be used in the window decorations and when minimizedowner
- the owner WindowfxmlPath
- the path of the fxml file- Throws:
java.io.IOException
- if fxml file fails to load
-
FXMLDialogWrapper
public FXMLDialogWrapper(java.lang.String title, javafx.stage.Stage owner, java.lang.String fxmlPath) throws java.io.IOException
Creates an instance of a dialog and sets the specified title, owner and fxml file path.- Parameters:
title
- the titleowner
- the owner WindowfxmlPath
- the path of the fxml file- Throws:
java.io.IOException
- if fxml file fails to load
-
FXMLDialogWrapper
public FXMLDialogWrapper(java.lang.String title, javafx.scene.image.Image icon, java.lang.String fxmlPath) throws java.io.IOException
Creates an instance of a dialog and sets the specified title, icon and fxml file path.- Parameters:
title
- the titleicon
- the icon image for the to be used in the window decorations and when minimizedfxmlPath
- the path of the fxml file- Throws:
java.io.IOException
- if fxml file fails to load
-
FXMLDialogWrapper
public FXMLDialogWrapper(java.lang.String title, javafx.scene.image.Image icon, javafx.stage.Stage owner, java.lang.String fxmlPath) throws java.io.IOException
Creates an instance of a dialog and sets the specified title, icon, owner and fxml file path.- Parameters:
title
- the titleicon
- the icon image for the to be used in the window decorations and when minimizedowner
- the owner WindowfxmlPath
- the path of the fxml file- Throws:
java.io.IOException
- if fxml file fails to load
-
-
Method Detail
-
getLoader
public javafx.fxml.FXMLLoader getLoader()
Returns theFXMLLoader
that was used to load theDialog
.- Returns:
- the
FXMLLoader
object
-
getDialog
public javafx.scene.control.Dialog<ReturnType> getDialog()
Returns theDialog
as aDialog
object.- Returns:
- the
Dialog
object
-
getController
public Controller getController()
Returns the controller associated with theDialog
.- Returns:
- the
Controller
object
-
getController
public void getController(javafx.fxml.Initializable controller)
Defines the controller associated with theDialog
.- Parameters:
controller
- theController
object
-
showAndWait
public java.util.Optional<ReturnType> showAndWait()
Shows the dialog and waits for the user response (in other words, brings up a blocking dialog, with the returned value the users input).This method must be called on the JavaFX Application thread. Additionally, it must either be called from an input event handler or From the run method of a Runnable passed to
Platform.runLater
. It must not be called during animation or layout processing.- Returns:
- An
Optional
that contains the result. Refer to theDialog
class documentation for more detail. - Throws:
java.lang.IllegalStateException
- if this method is called on a thread other than the JavaFX Application Thread.java.lang.IllegalStateException
- if this method is called during animation or layout processing.
-
setTitle
public void setTitle(java.lang.String value)
Defines the title of theDialog
.- Parameters:
value
- the title to set.
-
setIcon
public void setIcon(javafx.scene.image.Image value)
Defines the icon image for theDialog
to be used in the window decorations and when minimized.- Parameters:
value
- the icon image
-
setOwner
public void setOwner(javafx.stage.Stage value)
Defines the owner Window for thisDialog
, or null for a top-level, unowned stage. This must be done prior to making the stage visible.- Parameters:
value
- the owner for this dialog.- Throws:
java.lang.IllegalStateException
- if this property is set after the stage has ever been made visible.java.lang.IllegalStateException
- if this stage is the primary stage.
-
setAlwaysOnTop
public void setAlwaysOnTop(boolean value)
Defines whether thisDialog
is kept on top of other windows.If some other window is already always-on-top then the relative order between these windows is unspecified (depends on platform).
There are differences in behavior between applications if a security manager is present. Applications with permissions are allowed to set "always on top" flag on a Stage. In applications without the proper permissions, an attempt to set the flag will be ignored and the property value will be restored to "false".
- Parameters:
value
- the value to set.
-
getTitle
public java.lang.String getTitle()
Returns the title of theDialog
.- Returns:
- the title
-
getIcon
public javafx.scene.image.Image getIcon()
Returns the icon image for theDialog
that is used in the window decorations and when minimized.- Returns:
- the icon image, null if no icon exists
-
getOwner
public javafx.stage.Stage getOwner()
Returns the owner Window for thisDialog
, or null for a top-level, unowned stage.- Returns:
- the owner for this dialog.
-
isAlwaysOnTop
public boolean isAlwaysOnTop()
Returns whether thisDialog
is kept on top of other windows.If some other window is already always-on-top then the relative order between these windows is unspecified (depends on platform).
There are differences in behavior between applications if a security manager is present. Applications with permissions are allowed to set "always on top" flag on a Stage. In applications without the proper permissions, an attempt to set the flag will be ignored and the property value will be restored to "false".
- Returns:
- if dialog is kept on top of other windows
-
equals
public boolean equals(java.lang.Object o)
- Overrides:
equals
in classjava.lang.Object
-
hashCode
public int hashCode()
- Overrides:
hashCode
in classjava.lang.Object
-
toString
public java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
-
-