Class Notification


  • public class Notification
    extends Object
    A Notification Message similar to a popup window, but without disrupting the user's workflow. Non-modal info panel that vanishes after a certain time. This class only holds the data for a notification, NotificationManager is responsible for building the message panel and displaying it on screen. example:
          Notification note = new Notification("Hi there!");
          note.setIcon(JOptionPane.INFORMATION_MESSAGE); // optional
          note.setDuration(Notification.TIME_SHORT); // optional
          note.show();
     
    • Constructor Detail

      • Notification

        public Notification()
        Constructs a new Notification without content.
      • Notification

        public Notification​(String msg)
        Constructs a new Notification with the given textual content.
        Parameters:
        msg - The text to display
    • Method Detail

      • setContent

        public Notification setContent​(String msg)
        Set the notification text. (Convenience method)
        Parameters:
        msg - the message String. Will be wrapped in <html>, so you can use <br> and other markup directly.
        Returns:
        the current Object, for convenience
        See Also:
        Notification(java.lang.String)
      • setIcon

        public Notification setIcon​(Icon icon)
        Set an icon to display on the left part of the message window.
        Parameters:
        icon - the icon (null means no icon is displayed)
        Returns:
        the current Object, for convenience
      • setIcon

        public Notification setIcon​(int messageType)
        Set an icon to display on the left part of the message window by choosing from the default JOptionPane icons.
        Parameters:
        messageType - one of the following: JOptionPane.ERROR_MESSAGE, JOptionPane.INFORMATION_MESSAGE, JOptionPane.WARNING_MESSAGE, JOptionPane.QUESTION_MESSAGE, JOptionPane.PLAIN_MESSAGE
        Returns:
        the current Object, for convenience
      • setHelpTopic

        public Notification setHelpTopic​(String helpTopic)
        Display a help button at the bottom of the notification window.
        Parameters:
        helpTopic - the help topic
        Returns:
        the current Object, for convenience
      • getContent

        public Component getContent()
        Gets the content component to use.
        Returns:
        The content
      • getDuration

        public int getDuration()
        Gets the time the notification should be displayed
        Returns:
        The time to display the notification
      • getIcon

        public Icon getIcon()
        Gets the icon that should be displayed next to the notification
        Returns:
        The icon to display
      • getHelpTopic

        public String getHelpTopic()
        Gets the help topic for this notification
        Returns:
        The help topic
      • show

        public void show()
        Display the notification.
      • replaceExisting

        public void replaceExisting​(Notification oldNotification)
        Display the notification by replacing the given queued/displaying notification
        Parameters:
        oldNotification - the notification to replace
        Since:
        17628