Package swingtree.dialogs
Class MessageDialog
java.lang.Object
swingtree.dialogs.MessageDialog
An immutable builder class for creating simple message dialogs (errors, warnings, infos...)
based on the
JOptionPane
class, more specifically the
JOptionPane.showMessageDialog(Component, Object, String, int, Icon)
method.
This class is intended to be used as part of the UI
API
by calling the UIFactoryMethods.message(String)
factory method.
-
Method Summary
Modifier and TypeMethodDescriptionSet the icon of the dialog as a path to the icon resource.Set the icon of the dialog as anIcon
.icon
(IconDeclaration icon) Defines the icon which should be displayed alongside the message in terms of anIconDeclaration
, which is a constant object holding the path to the icon resource and the preferred size of the icon.Set the parent of the dialog.static MessageDialog
void
show()
Show the dialog with the specified configuration.void
Show the dialog with the specified configuration as an error dialog.void
Show the dialog with the specified configuration as an info dialog.void
Show the dialog with the specified configuration as a warning dialog.Set the title of the dialog.
-
Method Details
-
saying
-
titled
Set the title of the dialog.- Parameters:
title
- The title of the dialog.- Returns:
- A new
MessageDialog
instance with the specified title.
-
icon
Defines the icon which should be displayed alongside the message in terms of anIconDeclaration
, which is a constant object holding the path to the icon resource and the preferred size of the icon. Consider using this over theicon(Icon)
method to avoid resource loading issues as this approach ensures that the icon is loaded and cached only once.
A failure to load the icon will result in the default icon being displayed.- Parameters:
icon
- The icon declaration to find the icon.- Returns:
- A new
MessageDialog
instance with the specified icon.
-
icon
Set the icon of the dialog as anIcon
. Consider using theicon(IconDeclaration)
method to avoid resource loading issues.- Parameters:
icon
- The icon of the dialog.- Returns:
- A new
MessageDialog
instance with the specified icon.
-
icon
Set the icon of the dialog as a path to the icon resource. Consider using theicon(IconDeclaration)
method to avoid resource loading issues.- Parameters:
path
- The path to the icon resource.- Returns:
- A new
MessageDialog
instance with the specified icon.
-
parent
Set the parent of the dialog.- Parameters:
parent
- The parent of the dialog.- Returns:
- A new
MessageDialog
instance with the specified parent.
-
showAsError
public void showAsError()Show the dialog with the specified configuration as an error dialog. -
showAsWarning
public void showAsWarning()Show the dialog with the specified configuration as a warning dialog. -
showAsInfo
public void showAsInfo()Show the dialog with the specified configuration as an info dialog. -
show
public void show()Show the dialog with the specified configuration.
-