Class MessageDialog

java.lang.Object
swingtree.dialogs.MessageDialog

public final class MessageDialog extends Object
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 Details

    • saying

      public static MessageDialog saying(String text)
    • titled

      public MessageDialog titled(String title)
      Set the title of the dialog.
      Parameters:
      title - The title of the dialog.
      Returns:
      A new MessageDialog instance with the specified title.
    • icon

      public MessageDialog icon(IconDeclaration icon)
      Defines the icon which should be displayed alongside the message in terms of an IconDeclaration, which is a constant object holding the path to the icon resource and the preferred size of the icon. Consider using this over the icon(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

      public MessageDialog icon(Icon icon)
      Set the icon of the dialog as an Icon. Consider using the icon(IconDeclaration) method to avoid resource loading issues.
      Parameters:
      icon - The icon of the dialog.
      Returns:
      A new MessageDialog instance with the specified icon.
    • icon

      public MessageDialog icon(String path)
      Set the icon of the dialog as a path to the icon resource. Consider using the icon(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

      public MessageDialog parent(Component 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.