java.lang.Object
qupath.fx.dialogs.Dialogs
Collection of static methods to help with showing information to a user,
as well as requesting some basic input.
In general, 'showABCMessage' produces a dialog box that requires input from the user. By contrast, 'showABCNotification' shows a notification message that will disappear without user input - but only if ControlsFX is available. If ControlsFX is not available, the notification will be shown as a non-blocking dialog box.
Important! > It is recommended to call #setPrimaryWindow(Window) before using any of these methods, to help ensure that the dialogs are shown in the correct place when an owner is not specified.
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic class
Builder class to create a customDialog
. -
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic Dialogs.Builder
builder()
Create a new builder to generate a custom dialog.static javafx.collections.ObservableList<String>
Get a modifiable list of known file extensions.static javafx.stage.Window
Get the primary window.static void
static void
setPrimaryWindow
(javafx.stage.Window window) Set the primary window, which will be used as the owner of dialogs if no other window takes precedence (e.g.static <T> T
showChoiceDialog
(String title, String message, Collection<T> choices, T defaultChoice) Show a choice dialog with a collection of choices (selection from ComboBox or similar).static <T> T
showChoiceDialog
(String title, String message, T[] choices, T defaultChoice) Show a choice dialog with an array of choices (selection from ComboBox or similar).static boolean
showConfirmDialog
(String title, String text) Show a confirm dialog (OK/Cancel).static boolean
showConfirmDialog
(String title, javafx.scene.Node node) Show a confirm dialog (OK/Cancel).static void
showErrorMessage
(String title, String message) Show an error message.static void
showErrorMessage
(String title, Throwable e) Show an error message, displaying the localized message of aThrowable
.static void
showErrorMessage
(String title, javafx.scene.Node node) Show an error message, with the content defined within aNode
.static void
showErrorNotification
(String title, String message) Show an error notification.static void
showErrorNotification
(String title, Throwable e) Show an error notification, displaying the localized message of aThrowable
.static void
showInfoNotification
(String title, String message) Show an info notification.static Double
showInputDialog
(String title, String message, Double initialInput) Show an input dialog requesting a numeric value.static String
showInputDialog
(String title, String message, String initialInput) Show an input dialog requesting a String input.static boolean
showMessageDialog
(String title, String message) Show a standard message dialog.static boolean
showMessageDialog
(String title, javafx.scene.Node node) Show a message dialog (OK button only), with the content contained within a Node.static void
showPlainMessage
(String title, String message) Show a plain message.static void
showPlainNotification
(String title, String message) Show a plain notification.static void
showTextWindow
(javafx.stage.Window owner, String title, String contents, javafx.stage.Modality modality, boolean isEditable) Show a window containing plain text, with the specified properties.static void
showWarningNotification
(String title, String message) Show a warning notification.static javafx.scene.control.ButtonType
showYesNoCancelDialog
(String title, String text) Show a Yes/No/Cancel dialog.static boolean
showYesNoDialog
(String title, String text) Show a Yes/No dialog.
-
Constructor Details
-
Dialogs
public Dialogs()
-
-
Method Details
-
setPrimaryWindow
public static void setPrimaryWindow(javafx.stage.Window window) Set the primary window, which will be used as the owner of dialogs if no other window takes precedence (e.g. because it is modal or in focus).- Parameters:
window
-- See Also:
-
getPrimaryWindow
public static javafx.stage.Window getPrimaryWindow()Get the primary window.- Returns:
- See Also:
-
getKnownFileExtensions
Get a modifiable list of known file extensions. This exists to make it possible to override the logic of 'everything after the last dot is the file extension', and support multi-part extensions such as.tar.gz
or.ome.tif
.- Returns:
-
showConfirmDialog
Show a confirm dialog (OK/Cancel).- Parameters:
title
-text
-- Returns:
-
showMessageDialog
Show a message dialog (OK button only), with the content contained within a Node.- Parameters:
title
-node
-- Returns:
-
showMessageDialog
Show a standard message dialog.- Parameters:
title
-message
-- Returns:
-
showConfirmDialog
Show a confirm dialog (OK/Cancel).- Parameters:
title
-node
-- Returns:
-
showYesNoDialog
Show a Yes/No dialog.- Parameters:
title
-text
-- Returns:
-
showYesNoCancelDialog
Show a Yes/No/Cancel dialog.- Parameters:
title
- dialog box titletext
- prompt message- Returns:
- a
ButtonType
of YES, NO or CANCEL
-
showInputDialog
Show an input dialog requesting a numeric value. Only scientific notation and digits with/without a decimal separator (e.g. ".") are permitted.The returned value might still not be in a valid state, as limited by
FXUtils.restrictTextFieldInputToNumber(javafx.scene.control.TextField, boolean)
.- Parameters:
title
-message
-initialInput
-- Returns:
- Number input by the user, or NaN if no valid number was entered, or null if cancel was pressed.
- See Also:
-
showInputDialog
Show an input dialog requesting a String input.- Parameters:
title
-message
-initialInput
-- Returns:
-
showChoiceDialog
Show a choice dialog with an array of choices (selection from ComboBox or similar).- Type Parameters:
T
-- Parameters:
title
- dialog titlemessage
- dialog promptchoices
- array of available optionsdefaultChoice
- initial selected option- Returns:
- chosen option, or
null
if the user cancels the dialog
-
showChoiceDialog
public static <T> T showChoiceDialog(String title, String message, Collection<T> choices, T defaultChoice) Show a choice dialog with a collection of choices (selection from ComboBox or similar).- Type Parameters:
T
-- Parameters:
title
- dialog titlemessage
- dialog promptchoices
- list of available optionsdefaultChoice
- initial selected option- Returns:
- chosen option, or
null
if the user cancels the dialog
-
showErrorMessage
Show an error message, displaying the localized message of aThrowable
.- Parameters:
title
-e
-
-
showErrorNotification
Show an error notification, displaying the localized message of aThrowable
.- Parameters:
title
-e
-
-
showErrorNotification
Show an error notification.- Parameters:
title
-message
-
-
showWarningNotification
Show a warning notification.- Parameters:
title
-message
-
-
showInfoNotification
Show an info notification.- Parameters:
title
-message
-
-
showPlainNotification
Show a plain notification.- Parameters:
title
-message
-
-
showErrorMessage
Show an error message.- Parameters:
title
-message
-
-
showErrorMessage
Show an error message, with the content defined within aNode
.- Parameters:
title
-node
-
-
showPlainMessage
Show a plain message.- Parameters:
title
-message
-
-
showTextWindow
public static void showTextWindow(javafx.stage.Window owner, String title, String contents, javafx.stage.Modality modality, boolean isEditable) Show a window containing plain text, with the specified properties.- Parameters:
owner
-title
-contents
-modality
-isEditable
-
-
builder
Create a new builder to generate a custom dialog.- Returns:
-
main
-