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
Nested ClassesModifier and TypeClassDescriptionstatic classBuilder class to create a customDialog. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic Dialogs.Builderbuilder()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.WindowGet the primary window.static voidstatic voidsetPrimaryWindow(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> TshowChoiceDialog(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> TshowChoiceDialog(String title, String message, T[] choices, T defaultChoice) Show a choice dialog with an array of choices (selection from ComboBox or similar).static booleanshowConfirmDialog(String title, String text) Show a confirm dialog (OK/Cancel).static booleanshowConfirmDialog(String title, javafx.scene.Node node) Show a confirm dialog (OK/Cancel).static voidshowErrorMessage(String title, String message) Show an error message.static voidshowErrorMessage(String title, Throwable e) Show an error message, displaying the localized message of aThrowable.static voidshowErrorMessage(String title, javafx.scene.Node node) Show an error message, with the content defined within aNode.static voidshowErrorNotification(String title, String message) Show an error notification.static voidshowErrorNotification(String title, Throwable e) Show an error notification, displaying the localized message of aThrowable.static voidshowInfoNotification(String title, String message) Show an info notification.static DoubleshowInputDialog(String title, String message, Double initialInput) Show an input dialog requesting a numeric value.static StringshowInputDialog(String title, String message, String initialInput) Show an input dialog requesting a String input.static booleanshowMessageDialog(String title, String message) Show a standard message dialog.static booleanshowMessageDialog(String title, javafx.scene.Node node) Show a message dialog (OK button only), with the content contained within a Node.static voidshowPlainMessage(String title, String message) Show a plain message.static voidshowPlainNotification(String title, String message) Show a plain notification.static voidshowTextWindow(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 voidshowWarningNotification(String title, String message) Show a warning notification.static javafx.scene.control.ButtonTypeshowYesNoCancelDialog(String title, String text) Show a Yes/No/Cancel dialog.static booleanshowYesNoDialog(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.gzor.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
ButtonTypeof 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
nullif 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
nullif 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
-