Package docking.widgets
Class OptionDialog
java.lang.Object
docking.DialogComponentProvider
docking.widgets.OptionDialog
- All Implemented Interfaces:
ActionContextProvider
,StatusListener
,TaskListener
- Direct Known Subclasses:
OkDialog
A utility class to easily show dialogs that require input from the user.
Option Dialogs
The primary type of dialog provided herein is the basic option dialog that allows the user to specify the buttons that appear on the dialog. By default, the given option text will appear as a button(s), followed by aCancel
button (you can call the
showOptionNoCancelDialog(Component, String, String, String, String, int)
methods if
you do not want a Cancel
button. To use this type of dialog you can use the
various showOptionDialog*
methods.
Each of the option dialog methods will return a result, which is a number indicating the choice made by the user. See each method for more details.
Data Input and Choice Dialogs
The methods listed here allow the user to either enter data from the keyboard or to choose from a pre-populated list of data.showInputChoiceDialog(Component, String, String, String[], String, int)
showInputMultilineDialog(Component, String, String, String)
showInputSingleLineDialog(Component, String, String, String)
Yes/No Dialogs
Finally, there are a series of methods that presentYes
and No
buttons in
a dialog. There are versions that do and do not have a Cancel
button.
Basic Message / Warning / Error Dialogs
If you would like to display a simple message to the user, but do not require input from the user, then you should use the various methods ofMsg
, such as
Msg.showInfo(Object, Component, String, Object)
.
Note, the user will be unable to select any text shown in the message area of the dialog.
"Apply to All" / "Don't Show Again"
For more advanced input dialog usage, to include allowing the user to tell the dialog to remember a particular decision, or to apply a given choice to all future request, seeOptionDialogBuilder
.- See Also:
-
Field Summary
Modifier and TypeFieldDescriptionstatic final int
Identifier for the cancel option.static final int
Used for error messages.static final int
Used for information messages.static final String
static final int
static final int
Identifier for option one.static final int
Identifier for option three.static final int
Identifier for option two.static final int
No icon is used.static final int
Used for questions.static final int
Used for warning messages.static final int
Fields inherited from class docking.DialogComponentProvider
applyButton, buttonPanel, cancelButton, dismissButton, okButton, rootPanel
-
Constructor Summary
ModifierConstructorDescriptionprotected
OptionDialog
(String title, String message, int messageType, Icon icon) Construct a simple informational dialog with a single OK button.protected
OptionDialog
(String title, String message, String option1, int messageType, Icon icon) Construct a simple one-option dialog with a Cancel button.protected
OptionDialog
(String title, String message, String option1, int messageType, Icon icon, String defaultButtonName) Construct a simple one-option dialog with a Cancel button.protected
OptionDialog
(String title, String message, String option1, String option2, int messageType, Icon icon, boolean addCancel) Construct a simple two-option dialog.protected
OptionDialog
(String title, String message, String option1, String option2, int messageType, Icon icon, boolean addCancel, String defaultButtonName) Construct a simple two-option dialog.protected
OptionDialog
(String title, String message, String option1, String option2, String option3, int messageType, Icon icon, boolean addCancel) -
Method Summary
Modifier and TypeMethodDescriptionprotected void
Callback for when the cancel button is pressed.static OptionDialogBuilder
createBuilder
(String title, String message) A convenience method to create aOptionDialogBuilder
protected JPanel
createTextPanel
(String message) static Icon
getIconForMessageType
(int messageType) Returns the Icon to use for the given message type.Returns the dialog's message to the userfinal int
Returns which option was selected: CANCEL_OPTION if the operation was cancelled; OPTION_ONE if Option 1 was selected; OPTION_TWO if Option 2 was selected.protected void
callback for when the "OK" button is pressed.int
show()
int
static String
showEditableInputChoiceDialog
(Component parent, String title, String label, String[] selectableValues, String initialValue, int messageType) Displays a dialog for the user to enter a string value by either typing it or selecting from a list of possible strings.static String
showInputChoiceDialog
(Component parent, String title, String label, String[] selectableValues, String initialValue, int messageType) Displays a dialog for the user to enter a string value by either typing it or selecting from a list of possible strings.static String
showInputMultilineDialog
(Component parent, String title, String label, String initialValue) Displays a dialog for the user to enter a multi-line string value.static String
showInputSingleLineDialog
(Component parent, String title, String label, String initialValue) Displays a dialog for the user to enter a string value on a single line.static int
showOptionDialog
(Component parent, String title, String message, String option1) Static helper method to easily display an single-option dialog.static int
showOptionDialog
(Component parent, String title, String message, String option1, int messageType) Static helper method to easily display an single-option dialog.static int
showOptionDialog
(Component parent, String title, String message, String option1, int messageType, String defaultButtonName) Static helper method to easily display an single-option dialog.static int
Static helper method to easily display an two-option dialog.static int
showOptionDialog
(Component parent, String title, String message, String option1, String option2, int messageType) Static helper method to easily display an two-option dialog.static int
showOptionDialog
(Component parent, String title, String message, String option1, String option2, String option3, int messageType) Static helper method to easily display an three-option dialog.static int
showOptionDialog
(Component parent, String title, String message, String option1, String option2, Icon icon) Static helper method to easily display an two-option dialog.static int
Static helper method to easily display an single-option dialog.static int
showOptionDialogWithCancelAsDefaultButton
(Component parent, String title, String message, String option1) Static helper method to easily display an single-option dialog.static int
showOptionDialogWithCancelAsDefaultButton
(Component parent, String title, String message, String option1, int messageType) Static helper method to easily display an single-option dialog.static int
showOptionNoCancelDialog
(Component parent, String title, String message, String option1, String option2, int messageType) Static helper method to easily display an two-option dialog.static int
showOptionNoCancelDialog
(Component parent, String title, String message, String option1, String option2, String option3, int messageType) Static helper method to easily display an three-option dialog with no Cancel button.static int
showOptionNoCancelDialog
(Component parent, String title, String message, String option1, String option2, String option3, int messageType, HelpLocation help) Static helper method to easily display an three-option dialog with no Cancel button.static int
showOptionNoCancelDialog
(Component parent, String title, String message, String option1, String option2, Icon icon) Static helper method to easily display an two-option dialog with no Cancel button.static int
showYesNoCancelDialog
(Component parent, String title, String message) Dialog with only YES/NO options, no CANCELstatic int
showYesNoDialog
(Component parent, String title, String message) Dialog with only YES/NO options, no CANCELstatic int
showYesNoDialogWithNoAsDefaultButton
(Component parent, String title, String message) Dialog with only YES/NO options, no CANCELMethods inherited from class docking.DialogComponentProvider
addAction, addApplyButton, addButton, addCancelButton, addDismissButton, addOKButton, addWorkPanel, alertMessage, alertMessage, applyCallback, cancelCurrentTask, clearScheduledTask, clearStatusText, close, closeDialog, dialogClosed, dialogShown, dismissCallback, dispose, doInitialize, escapeCallback, executeProgressTask, getActionContext, getActions, getBackground, getBounds, getComponent, getDefaultButton, getDefaultSize, getDialogSize, getFocusComponent, getGlassPane, getHelpLocation, getId, getInitialLocation, getLocationOnScreen, getParent, getPreferredSize, getRememberLocation, getRememberSize, getStatusColor, getStatusLabel, getStatusText, getTaskMonitorComponent, getTaskScheduler, getTitle, getUseSharedLocation, hideTaskMonitorComponent, isApplyEnabled, isCancelEnabled, isModal, isOKEnabled, isResizeable, isRunningTask, isShowing, isTransient, isVisible, notifyContextChanged, removeAction, removeButton, removeWorkPanel, repack, setAccessibleDescription, setApplyEnabled, setApplyToolTip, setBackground, setCancelButtonText, setCancelEnabled, setCancelToolTip, setCursor, setDefaultButton, setDefaultSize, setDialogSize, setDismissToolTip, setFocusComponent, setGlassPane, setHelpLocation, setInitialLocation, setMinimumSize, setMinimumSize, setOkButtonText, setOkEnabled, setOkToolTip, setPreferredSize, setRememberLocation, setRememberSize, setResizable, setStatusJustification, setStatusText, setStatusText, setStatusText, setTitle, setTransient, setUseSharedLocation, showProgressBar, showTaskMonitorComponent, stopProgressTimer, taskCancelled, taskCompleted, toFront, toString, waitForCurrentTask
-
Field Details
-
MESSAGE_COMPONENT_NAME
- See Also:
-
ERROR_MESSAGE
public static final int ERROR_MESSAGEUsed for error messages.- See Also:
-
INFORMATION_MESSAGE
public static final int INFORMATION_MESSAGEUsed for information messages.- See Also:
-
WARNING_MESSAGE
public static final int WARNING_MESSAGEUsed for warning messages.- See Also:
-
QUESTION_MESSAGE
public static final int QUESTION_MESSAGEUsed for questions.- See Also:
-
PLAIN_MESSAGE
public static final int PLAIN_MESSAGENo icon is used.- See Also:
-
CANCEL_OPTION
public static final int CANCEL_OPTIONIdentifier for the cancel option.- See Also:
-
YES_OPTION
public static final int YES_OPTION- See Also:
-
NO_OPTION
public static final int NO_OPTION- See Also:
-
OPTION_ONE
public static final int OPTION_ONEIdentifier for option one.- See Also:
-
OPTION_TWO
public static final int OPTION_TWOIdentifier for option two.- See Also:
-
OPTION_THREE
public static final int OPTION_THREEIdentifier for option three.- See Also:
-
-
Constructor Details
-
OptionDialog
Construct a simple informational dialog with a single OK button.- Parameters:
title
- The String to be placed in the dialogs title area.message
- The information message to be displayed in the dialog.messageType
- used to specify a default icon- ERROR_MESSAGE
- INFORMATION_MESSAGE
- WARNING_MESSAGE
- QUESTION_MESSAGE
- PLAIN_MESSAGE
icon
- allows the user to specify the icon to be used. If non-null, this will override the messageType.
-
OptionDialog
protected OptionDialog(String title, String message, String option1, String option2, int messageType, Icon icon, boolean addCancel) Construct a simple two-option dialog.- Parameters:
title
- the String to place in the dialog's title area.message
- the message string explaining the user's option.option1
- The text to place on the first option button.option2
- The text to place on the second option button.messageType
- used to specify a default icon, can be ERROR_MESSAGE, INFORMATION_MESSAGE, WARNING_MESSAGE, QUESTION_MESSAGE, or PLAIN_MESSAGE)icon
- allows the user to specify the icon to be used. If non-null, this will override the messageType.addCancel
- true means add a Cancel button
-
OptionDialog
protected OptionDialog(String title, String message, String option1, String option2, int messageType, Icon icon, boolean addCancel, String defaultButtonName) Construct a simple two-option dialog.- Parameters:
title
- the String to place in the dialog's title area.message
- the message string explaining the user's option.option1
- The text to place on the first option button.option2
- The text to place on the second option button.messageType
- used to specify a default icon, can be ERROR_MESSAGE, INFORMATION_MESSAGE, WARNING_MESSAGE, QUESTION_MESSAGE, or PLAIN_MESSAGE)icon
- allows the user to specify the icon to be used. If non-null, this will override the messageType.addCancel
- true means add a Cancel buttondefaultButtonName
- The default button name
-
OptionDialog
Construct a simple one-option dialog with a Cancel button.- Parameters:
title
- the String to place in the dialog's title area.message
- the message string explaining the user's option.option1
- The text to place on the first option button.messageType
- used to specify a default icon, can be ERROR_MESSAGE, INFORMATION_MESSAGE, WARNING_MESSAGE, QUESTION_MESSAGE, or PLAIN_MESSAGE)icon
- allows the user to specify the icon to be used. If non-null, this will override the messageType.
-
OptionDialog
protected OptionDialog(String title, String message, String option1, int messageType, Icon icon, String defaultButtonName) Construct a simple one-option dialog with a Cancel button.- Parameters:
title
- the String to place in the dialog's title area.message
- the message string explaining the user's option.option1
- The text to place on the first option button.messageType
- used to specify a default icon, can be ERROR_MESSAGE, INFORMATION_MESSAGE, WARNING_MESSAGE, QUESTION_MESSAGE, or PLAIN_MESSAGE)icon
- allows the user to specify the icon to be used. If non-null, this will override the messageType.defaultButtonName
- the name of the button to be made the default.
-
OptionDialog
-
-
Method Details
-
createTextPanel
-
getMessage
Returns the dialog's message to the user- Returns:
- the message
-
show
public int show() -
show
-
createBuilder
A convenience method to create aOptionDialogBuilder
- Parameters:
title
- the dialog titlemessage
- the dialog message- Returns:
- the builder
-
showOptionDialog
Static helper method to easily display an single-option dialog. The dialog will remain until the user presses the Option1 button or the Cancel button.- Parameters:
parent
- The parent component of this dialog. If the given component is a frame or dialog, then the component will be used to parent the option dialog. Otherwise, the parent frame or dialog will be found by traversing up the given component's parent hierarchy. Also, null can be used to not parent the dialog at all, but this promotes poor dialog behaviortitle
- The String to be placed in the dialogs title area.message
- The information message to be displayed in the dialog.option1
- The text to place on the option button.- Returns:
- The options selected by the user. 1 if the option button is pressed or 0 if the operation is cancelled.
-
showOptionDialogWithCancelAsDefaultButton
public static int showOptionDialogWithCancelAsDefaultButton(Component parent, String title, String message, String option1) Static helper method to easily display an single-option dialog. The dialog will remain until the user presses the Option1 button or the Cancel button.The dialog shown by this method will have the cancel button set as the default button so that an Enter key press will trigger a cancel action.
- Parameters:
parent
- The parent component of this dialog. If the given component is a frame or dialog, then the component will be used to parent the option dialog. Otherwise, the parent frame or dialog will be found by traversing up the given component's parent hierarchy. Also, null can be used to not parent the dialog at all, but this promotes poor dialog behaviortitle
- The String to be placed in the dialogs title area.message
- The information message to be displayed in the dialog.option1
- The text to place on the option button.- Returns:
- The options selected by the user. 1 if the option button is pressed or 0 if the operation is cancelled.
-
showOptionDialogWithCancelAsDefaultButton
public static int showOptionDialogWithCancelAsDefaultButton(Component parent, String title, String message, String option1, int messageType) Static helper method to easily display an single-option dialog. The dialog will remain until the user presses the Option1 button or the Cancel button.The dialog shown by this method will have the cancel button set as the default button so that an Enter key press will trigger a cancel action.
- Parameters:
parent
- The parent component of this dialog. If the given component is a frame or dialog, then the component will be used to parent the option dialog. Otherwise, the parent frame or dialog will be found by traversing up the given component's parent hierarchy. Also, null can be used to not parent the dialog at all, but this promotes poor dialog behaviortitle
- The String to be placed in the dialogs title area.message
- The information message to be displayed in the dialog.option1
- The text to place on the option button.messageType
- used to specify a default icon, can be ERROR_MESSAGE, INFORMATION_MESSAGE, WARNING_MESSAGE, QUESTION_MESSAGE, or PLAIN_MESSAGE)- Returns:
- The options selected by the user. 1 if the option button is pressed or 0 if the operation is cancelled.
-
showOptionDialog
public static int showOptionDialog(Component parent, String title, String message, String option1, int messageType) Static helper method to easily display an single-option dialog. The dialog will remain until the user presses the Option1 button or the Cancel button.- Parameters:
parent
- The parent component of this dialog. If the given component is a frame or dialog, then the component will be used to parent the option dialog. Otherwise, the parent frame or dialog will be found by traversing up the given component's parent hierarchy. Also, null can be used to not parent the dialog at all, but this promotes poor dialog behaviortitle
- The String to be placed in the dialogs title area.message
- The information message to be displayed in the dialog.option1
- The text to place on the option button.messageType
- used to specify a default icon, can be ERROR_MESSAGE, INFORMATION_MESSAGE, WARNING_MESSAGE, QUESTION_MESSAGE, or PLAIN_MESSAGE)- Returns:
- The options selected by the user. 1 if the option button is pressed or 0 if the operation is cancelled.
-
showOptionDialog
public static int showOptionDialog(Component parent, String title, String message, String option1, int messageType, String defaultButtonName) Static helper method to easily display an single-option dialog. The dialog will remain until the user presses the Option1 button or the Cancel button.- Parameters:
parent
- The parent component of this dialog. If the given component is a frame or dialog, then the component will be used to parent the option dialog. Otherwise, the parent frame or dialog will be found by traversing up the given component's parent hierarchy. Also, null can be used to not parent the dialog at all, but this promotes poor dialog behaviortitle
- The String to be placed in the dialogs title area.message
- The information message to be displayed in the dialog.option1
- The text to place on the option button.messageType
- used to specify a default icon, can be ERROR_MESSAGE, INFORMATION_MESSAGE, WARNING_MESSAGE, QUESTION_MESSAGE, or PLAIN_MESSAGE)defaultButtonName
- the name of the button to be the default. Null will make the first button the default- Returns:
- The options selected by the user. 1 if the option button is pressed or 0 if the operation is cancelled.
-
showOptionDialog
public static int showOptionDialog(Component parent, String title, String message, String option1, Icon icon) Static helper method to easily display an single-option dialog. The dialog will remain until the user presses the Option1 button or the Cancel button.- Parameters:
parent
- The parent component of this dialog. If the given component is a frame or dialog, then the component will be used to parent the option dialog. Otherwise, the parent frame or dialog will be found by traversing up the given component's parent hierarchy. Also, null can be used to not parent the dialog at all, but this promotes poor dialog behaviortitle
- The String to be placed in the dialogs title area.message
- The information message to be displayed in the dialog.option1
- The text to place on the option button.icon
- allows the user to specify the icon to be used. If non-null, this will override the messageType.- Returns:
- The options selected by the user. 1 if the option button is pressed or 0 if the operation is cancelled.
-
showOptionDialog
public static int showOptionDialog(Component parent, String title, String message, String option1, String option2, String option3, int messageType) Static helper method to easily display an three-option dialog. The dialog will remain until the user presses the Option1, Option2, Option3 or Cancel button.- Parameters:
parent
- The parent component of this dialog. If the given component is a frame or dialog, then the component will be used to parent the option dialog. Otherwise, the parent frame or dialog will be found by traversing up the given component's parent hierarchy. Also, null can be used.title
- The String to be placed in the dialogs title area.message
- The information message to be displayed in the dialog.option1
- The text to place on the first option button.option2
- The text to place on the second option button.option3
- The text to place on the third option button.messageType
- The type of message to display- Returns:
- The options selected by the user. 1 for the first option and 2 for the second option and so on. 0 is returned if the operation is cancelled.
-
showOptionDialog
public static int showOptionDialog(Component parent, String title, String message, String option1, String option2) Static helper method to easily display an two-option dialog. The dialog will remain until the user presses the Option1, Option2 or Cancel button.- Parameters:
parent
- The parent component of this dialog. If the given component is a frame or dialog, then the component will be used to parent the option dialog. Otherwise, the parent frame or dialog will be found by traversing up the given component's parent hierarchy. Also, null can be used to not parent the dialog at all, but this promotes poor dialog behaviortitle
- The String to be placed in the dialogs title area.message
- The information message to be displayed in the dialog.option1
- The text to place on the first option button.option2
- The text to place on the second option button.\- Returns:
- The options selected by the user. 1 for the first option and 2 for the second option. 0 is returned if the operation is cancelled.
-
showOptionDialog
public static int showOptionDialog(Component parent, String title, String message, String option1, String option2, int messageType) Static helper method to easily display an two-option dialog. The dialog will remain until the user presses the Option1, Option2 or Cancel button.- Parameters:
parent
- The parent component of this dialog. If the given component is a frame or dialog, then the component will be used to parent the option dialog. Otherwise, the parent frame or dialog will be found by traversing up the given component's parent hierarchy. Also, null can be used to not parent the dialog at all, but this promotes poor dialog behaviortitle
- The String to be placed in the dialogs title area.message
- The information message to be displayed in the dialog.option1
- The text to place on the first option button.option2
- The text to place on the second option button.messageType
- used to specify a default icon, can be ERROR_MESSAGE, INFORMATION_MESSAGE, WARNING_MESSAGE, QUESTION_MESSAGE, or PLAIN_MESSAGE)- Returns:
- The options selected by the user. 1 for the first option and 2 for the second option. 0 is returned if the operation is cancelled.
-
showOptionDialog
public static int showOptionDialog(Component parent, String title, String message, String option1, String option2, Icon icon) Static helper method to easily display an two-option dialog. The dialog will remain until the user presses the Option1, Option2 or Cancel button.- Parameters:
parent
- The parent component of this dialog. If the given component is a frame or dialog, then the component will be used to parent the option dialog. Otherwise, the parent frame or dialog will be found by traversing up the given component's parent hierarchy. Also, null can be used to not parent the dialog at all, but this promotes poor dialog behaviortitle
- The String to be placed in the dialogs title area.message
- The information message to be displayed in the dialog.option1
- The text to place on the first option button.option2
- The text to place on the second option button.icon
- allows the user to specify the icon to be used. If non-null, this will override the messageType.- Returns:
- The options selected by the user. 1 for the first option and 2 for the second option. 0 is returned if the operation is cancelled.
-
showOptionNoCancelDialog
public static int showOptionNoCancelDialog(Component parent, String title, String message, String option1, String option2, int messageType) Static helper method to easily display an two-option dialog. The dialog will remain until the user presses the Option1, Option2 or Cancel button.- Parameters:
parent
- The parent component of this dialog. If the given component is a frame or dialog, then the component will be used to parent the option dialog. Otherwise, the parent frame or dialog will be found by traversing up the given component's parent hierarchy. Also, null can be used to not parent the dialog at all, but this promotes poor dialog behaviortitle
- The String to be placed in the dialogs title area.message
- The information message to be displayed in the dialog.option1
- The text to place on the first option button.option2
- The text to place on the second option button.messageType
- used to specify a default icon, can be ERROR_MESSAGE, INFORMATION_MESSAGE, WARNING_MESSAGE, QUESTION_MESSAGE, or PLAIN_MESSAGE)- Returns:
- The options selected by the user. 1 for the first option and 2 for the second option. 0 is returned if the operation is cancelled.
-
showOptionNoCancelDialog
public static int showOptionNoCancelDialog(Component parent, String title, String message, String option1, String option2, Icon icon) Static helper method to easily display an two-option dialog with no Cancel button. The dialog will remain until the user presses the Option1 or Option 2 button.- Parameters:
parent
- The parent component of this dialog. If the given component is a frame or dialog, then the component will be used to parent the option dialog. Otherwise, the parent frame or dialog will be found by traversing up the given component's parent hierarchy. Also, null can be used to not parent the dialog at all, but this promotes poor dialog behaviortitle
- The String to be placed in the dialogs title area.message
- The information message to be displayed in the dialog.option1
- The text to place on the first option button.option2
- The text to place on the second option button.icon
- allows the user to specify the icon to be used. If non-null, this will override the messageType.- Returns:
- The options selected by the user. 1 for the first option and 2 for the second option. 0 is returned if the operation is cancelled.
-
showOptionNoCancelDialog
public static int showOptionNoCancelDialog(Component parent, String title, String message, String option1, String option2, String option3, int messageType) Static helper method to easily display an three-option dialog with no Cancel button. The dialog will remain until the user presses the Option1, Option 2, or Option 3 button.- Parameters:
parent
- The parent component of this dialog. If the given component is a frame or dialog, then the component will be used to parent the option dialog. Otherwise, the parent frame or dialog will be found by traversing up the given component's parent hierarchy. Also, null can be used to not parent the dialog at all, but this promotes poor dialog behaviortitle
- The String to be placed in the dialogs title area.message
- The information message to be displayed in the dialog.option1
- The text to place on the first option button.option2
- The text to place on the second option button.option3
- The text to place on the third option button.messageType
- used to specify a default icon, can be ERROR_MESSAGE, INFORMATION_MESSAGE, WARNING_MESSAGE, QUESTION_MESSAGE, or PLAIN_MESSAGE)- Returns:
- The options selected by the user. 1 for the first option and 2 for the second option. 0 is returned if the operation is cancelled.
-
showOptionNoCancelDialog
public static int showOptionNoCancelDialog(Component parent, String title, String message, String option1, String option2, String option3, int messageType, HelpLocation help) Static helper method to easily display an three-option dialog with no Cancel button. The dialog will remain until the user presses the Option1, Option 2, or Option 3 button.- Parameters:
parent
- The parent component of this dialog. If the given component is a frame or dialog, then the component will be used to parent the option dialog. Otherwise, the parent frame or dialog will be found by traversing up the given component's parent hierarchy. Also, null can be used to not parent the dialog at all, but this promotes poor dialog behaviortitle
- The String to be placed in the dialogs title areamessage
- The information message to be displayed in the dialogoption1
- The text to place on the first option buttonoption2
- The text to place on the second option buttonoption3
- The text to place on the third option buttonmessageType
- used to specify a default icon, can be ERROR_MESSAGE, INFORMATION_MESSAGE, WARNING_MESSAGE, QUESTION_MESSAGE, or PLAIN_MESSAGE)help
- The help location for this dialog- Returns:
- The options selected by the user. 1 for the first option and 2 for the second option. 0 is returned if the operation is cancelled
-
showYesNoDialog
Dialog with only YES/NO options, no CANCEL- Parameters:
parent
- The parent dialog or frame of this dialog. (Can be null)title
- The String to be placed in the dialogs title area.message
- The information message to be displayed in the dialog.- Returns:
- The options selected by the user:
0 is returned if the operation is cancelled 1 for Yes 2 for No
-
showYesNoDialogWithNoAsDefaultButton
public static int showYesNoDialogWithNoAsDefaultButton(Component parent, String title, String message) Dialog with only YES/NO options, no CANCELThe dialog shown by this method will have the
No
button set as the default button so that an Enter key press will trigger aNo
action.- Parameters:
parent
- The parent component of this dialog. If the given component is a frame or dialog, then the component will be used to parent the option dialog. Otherwise, the parent frame or dialog will be found by traversing up the given component's parent hierarchy. Also, null can be used to not parent the dialog at all, but this promotes poor dialog behaviortitle
- The String to be placed in the dialogs title area.message
- The information message to be displayed in the dialog.- Returns:
- The options selected by the user:
1 for Yes 2 for No
-
showYesNoCancelDialog
Dialog with only YES/NO options, no CANCEL- Parameters:
parent
- The parent component of this dialog. If the given component is a frame or dialog, then the component will be used to parent the option dialog. Otherwise, the parent frame or dialog will be found by traversing up the given component's parent hierarchy. Also, null can be used to not parent the dialog at all, but this promotes poor dialog behaviortitle
- The String to be placed in the dialogs title area.message
- The information message to be displayed in the dialog.- Returns:
- The options selected by the user:
0 is returned if the operation is cancelled 1 for the first option 2 for the second option
-
showInputSingleLineDialog
public static String showInputSingleLineDialog(Component parent, String title, String label, String initialValue) Displays a dialog for the user to enter a string value on a single line.- Parameters:
parent
- the component to parent this dialog totitle
- the title to display on the input dialoglabel
- the label to display in front of the text fieldinitialValue
- an optional value to set in the text field, can be null- Returns:
- the string entered OR null if the dialog was canceled.
-
showInputMultilineDialog
public static String showInputMultilineDialog(Component parent, String title, String label, String initialValue) Displays a dialog for the user to enter a multi-line string value.- Parameters:
parent
- the component to parent this dialog totitle
- the title to display on the input dialoglabel
- the label to display in front of the text areainitialValue
- an optional value that will be set in the text area, can be null- Returns:
- the string entered OR null if the dialog was canceled.
-
showInputChoiceDialog
public static String showInputChoiceDialog(Component parent, String title, String label, String[] selectableValues, String initialValue, int messageType) Displays a dialog for the user to enter a string value by either typing it or selecting from a list of possible strings.- Parameters:
parent
- the component to parent this dialog totitle
- the title to display on the input dialoglabel
- the label to display in front of the combo boxselectableValues
- an array of string to choose frominitialValue
- an optional value to set the combo box to, can be null in which the combo box will have the first item from the selectable values.messageType
- used to specify a default icon, can be ERROR_MESSAGE, INFORMATION_MESSAGE, WARNING_MESSAGE, QUESTION_MESSAGE, or PLAIN_MESSAGE)- Returns:
- the string entered or chosen OR null if the dialog was canceled.
-
showEditableInputChoiceDialog
public static String showEditableInputChoiceDialog(Component parent, String title, String label, String[] selectableValues, String initialValue, int messageType) Displays a dialog for the user to enter a string value by either typing it or selecting from a list of possible strings. The list of possible values is editable such that the user can enter their own value by typing text.- Parameters:
parent
- the component to parent this dialog totitle
- the title to display on the input dialoglabel
- the label to display in front of the combo boxselectableValues
- an array of string to choose frominitialValue
- an optional value to set the combo box to, can be null in which the combo box will have the first item from the selectable values.messageType
- used to specify a default icon, can be ERROR_MESSAGE, INFORMATION_MESSAGE, WARNING_MESSAGE, QUESTION_MESSAGE, or PLAIN_MESSAGE)- Returns:
- the string entered or chosen OR null if the dialog was canceled.
-
getResult
public final int getResult()Returns which option was selected: CANCEL_OPTION if the operation was cancelled; OPTION_ONE if Option 1 was selected; OPTION_TWO if Option 2 was selected.- Returns:
- selected option; returns CANCEL_OPTION for informational dialogs
-
okCallback
protected void okCallback()callback for when the "OK" button is pressed.- Overrides:
okCallback
in classDialogComponentProvider
-
cancelCallback
protected void cancelCallback()Callback for when the cancel button is pressed.- Overrides:
cancelCallback
in classDialogComponentProvider
-
getIconForMessageType
Returns the Icon to use for the given message type.- Parameters:
messageType
- the type of message being displayed.- Returns:
- the appropriate Icon.
-