Class Messenger


  • public class Messenger
    extends java.lang.Object
    The Messenger manages the display of information and error messages for top-level windows. A queue of messages is maintained for each window. If a message is already displayed and a new message is posted, it will be added to a queue and shown after the current message and all queued messages have been displayed.

    Messages that do not explicitly return a result will return immediately, without waiting for the message to be displayed or dismissed.

    Since:
    3.0
    Author:
    Chris Jennings
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static void displayErrorMessage​(java.awt.Component parent, java.lang.String message)
      Displays an error message to the user.
      static void displayMessage​(java.awt.Component parent, java.lang.String message)
      Displays a message to the user.
      static void displayMessage​(java.awt.Component parent, java.lang.String iconResource, java.lang.String message)
      Displays a message to the user.
      static void displayMessage​(java.awt.Component parent, javax.swing.Icon icon, java.lang.String message)
      Displays a message to the user.
      static void displayMessage​(java.awt.Component parent, javax.swing.Icon icon, java.lang.String message, javax.swing.JComponent[] inlineComponents)
      Displays a message to the user.
      static void displayWarningMessage​(java.awt.Component parent, java.lang.String message)
      Displays a warning message to the user.
      static boolean isQueueProcessingEnabled()
      Returns true if the messages in message queues are actively being displayed.
      static void setQueueProcessingEnabled​(boolean enable)
      Enables or disables message queue processing.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Method Detail

      • displayWarningMessage

        public static void displayWarningMessage​(java.awt.Component parent,
                                                 java.lang.String message)
        Displays a warning message to the user. An warning message is used to warn that the user that an action they are about to take may have unexpected or irreversible consequences. (Compare this to displayErrorMessage(java.awt.Component, java.lang.String).)
        Parameters:
        parent - the component or window that this message relates to; if null, then the main application window will be the parent
        message - the text of the message
        Throws:
        java.lang.NullPointerException - if message is null
      • displayErrorMessage

        public static void displayErrorMessage​(java.awt.Component parent,
                                               java.lang.String message)
        Displays an error message to the user. An error message is used to report that a problem has occurred. (Compare this to displayWarningMessage(java.awt.Component, java.lang.String).)
        Parameters:
        parent - the component or window that this message relates to; if null, then the main application window will be the parent
        message - the text of the message
        Throws:
        java.lang.NullPointerException - if message is null
      • displayMessage

        public static void displayMessage​(java.awt.Component parent,
                                          java.lang.String iconResource,
                                          java.lang.String message)
        Displays a message to the user.
        Parameters:
        parent - the component or window that this message relates to; if null, then the main application window will be the parent
        iconResource - an optional image resource to display beside the message; this will be loaded using ResourceKit.getIcon(java.lang.String)
        message - the text of the message
        Throws:
        java.lang.NullPointerException - if message is null
      • displayMessage

        public static void displayMessage​(java.awt.Component parent,
                                          java.lang.String message)
        Displays a message to the user.
        Parameters:
        parent - the component or window that this message relates to; if null, then the main application window will be the parent
        message - the text of the message
        Throws:
        java.lang.NullPointerException - if message is null
      • displayMessage

        public static void displayMessage​(java.awt.Component parent,
                                          javax.swing.Icon icon,
                                          java.lang.String message)
        Displays a message to the user.
        Parameters:
        parent - the component or window that this message relates to; if null, then the main application window will be the parent
        icon - an optional icon to display beside the message
        message - the text of the message
        Throws:
        java.lang.NullPointerException - if message is null
      • displayMessage

        public static void displayMessage​(java.awt.Component parent,
                                          javax.swing.Icon icon,
                                          java.lang.String message,
                                          javax.swing.JComponent[] inlineComponents)
        Displays a message to the user.
        Parameters:
        parent - the component or window that this message relates to; if null, then the main application window will be the parent
        icon - an optional icon to display beside the message
        message - the text of the message
        inlineComponents - an array of interface components that will be included as part of the message by stacking them, one per row, under the main message text
        Throws:
        java.lang.NullPointerException - if message is null
      • setQueueProcessingEnabled

        public static void setQueueProcessingEnabled​(boolean enable)
        Enables or disables message queue processing. While queue processing is disabled, messages will continue to be queued but will not be displayed. When queue processing is reenabled, the display of messages in the queue will resume.
        Parameters:
        enable - whether queued messages should be displayed (true) or held for future display (false)
        See Also:
        isQueueProcessingEnabled()
      • isQueueProcessingEnabled

        public static boolean isQueueProcessingEnabled()
        Returns true if the messages in message queues are actively being displayed.
        Returns:
        true if queue processing is enabled