Class NotifyDescriptor

java.lang.Object
org.openide.NotifyDescriptor
Direct Known Subclasses:
DialogDescriptor, NotifyDescriptor.ComposedInput, NotifyDescriptor.Confirmation, NotifyDescriptor.InputLine, NotifyDescriptor.Message, NotifyDescriptor.QuickPick

public class NotifyDescriptor extends Object
This class provides a description of a user notification to be displayed.

Simple example of usage:

NotifyDescriptor d =
    new NotifyDescriptor.Message("Hello...", NotifyDescriptor.INFORMATION_MESSAGE);
DialogDisplayer.getDefault().notify(d);
or to get a result:
NotifyDescriptor d =
    new NotifyDescriptor.Confirmation("Really do this?!", "Dialog Title",
                                      NotifyDescriptor.OK_CANCEL_OPTION);
if (DialogDisplayer.getDefault().notify(d) == NotifyDescriptor.OK_OPTION) {
    // really do it...
}
See Also:
  • Field Details

    • PROP_MESSAGE

      public static final String PROP_MESSAGE
      Name of property for the message to be displayed.
      See Also:
    • PROP_MESSAGE_TYPE

      public static final String PROP_MESSAGE_TYPE
      Name of property for the type of message to use.
      See Also:
    • PROP_OPTION_TYPE

      public static final String PROP_OPTION_TYPE
      Name of property for the style of options available.
      See Also:
    • PROP_OPTIONS

      public static final String PROP_OPTIONS
      Name of property for the exact list of options.
      See Also:
    • PROP_VALUE

      public static final String PROP_VALUE
      Name of property for the value the user selected.
      See Also:
    • PROP_TITLE

      public static final String PROP_TITLE
      Name of property for the dialog title.
      See Also:
    • PROP_DETAIL

      public static final String PROP_DETAIL
      Name of property for the detail message reported.
      See Also:
    • PROP_VALID

      public static final String PROP_VALID
      Name of property for the OK button validation.
      See Also:
    • PROP_NO_DEFAULT_CLOSE

      public static final String PROP_NO_DEFAULT_CLOSE
      Name of property for toggling the ESC key and title frame button closing.
      Since:
      7.35
      See Also:
    • PROP_ERROR_NOTIFICATION

      public static final String PROP_ERROR_NOTIFICATION
      Name of property for the error message at the bottom of the wizard. To set such message use createNotificationLineSupport()
      Since:
      7.10
      See Also:
    • PROP_WARNING_NOTIFICATION

      public static final String PROP_WARNING_NOTIFICATION
      Name of property for the error message at the bottom of the wizard. To set such message use createNotificationLineSupport()
      Since:
      7.10
      See Also:
    • PROP_INFO_NOTIFICATION

      public static final String PROP_INFO_NOTIFICATION
      Name of property for the error message at the bottom of the wizard. To set such message use createNotificationLineSupport()
      Since:
      7.10
      See Also:
    • YES_OPTION

      public static final Object YES_OPTION
      Return value if YES is chosen.
    • NO_OPTION

      public static final Object NO_OPTION
      Return value if NO is chosen.
    • CANCEL_OPTION

      public static final Object CANCEL_OPTION
      Return value if CANCEL is chosen.
    • OK_OPTION

      public static final Object OK_OPTION
      Return value if OK is chosen.
    • CLOSED_OPTION

      public static final Object CLOSED_OPTION
      Return value if user closes the window without pressing any button.
    • DEFAULT_OPTION

      public static final int DEFAULT_OPTION
      Option type used by default.
      See Also:
    • YES_NO_OPTION

      public static final int YES_NO_OPTION
      Option type used for negatable confirmations.
      See Also:
    • YES_NO_CANCEL_OPTION

      public static final int YES_NO_CANCEL_OPTION
      Option type used for negatable and cancellable confirmations.
      See Also:
    • OK_CANCEL_OPTION

      public static final int OK_CANCEL_OPTION
      Option type used for cancellable confirmations.
      See Also:
    • ERROR_MESSAGE

      public static final int ERROR_MESSAGE
      Message type for error messages.
      See Also:
    • INFORMATION_MESSAGE

      public static final int INFORMATION_MESSAGE
      Message type for information messages.
      See Also:
    • WARNING_MESSAGE

      public static final int WARNING_MESSAGE
      Message type for warning messages.
      See Also:
    • QUESTION_MESSAGE

      public static final int QUESTION_MESSAGE
      Message type for questions.
      See Also:
    • PLAIN_MESSAGE

      public static final int PLAIN_MESSAGE
      Plain message type using no icon.
      See Also:
  • Constructor Details

    • NotifyDescriptor

      public NotifyDescriptor(Object message, String title, int optionType, int messageType, Object[] options, Object initialValue)
      Creates a new notify descriptor with specified information to report. If optionType is YES_NO_OPTION or YES_NO_CANCEL_OPTION and the options parameter is null, then the options are supplied by the look and feel. The messageType parameter is primarily used to supply a default icon from the look and feel.
      Parameters:
      message - the object to display
      title - the title string for the dialog
      optionType - indicates which options are available
      messageType - indicates what type of message should be displayed
      options - an array of objects indicating the possible choices
      initialValue - the object that represents the default value
      See Also:
  • Method Details

    • initialize

      protected void initialize()
      Method that is called before a value is returned from any of getter methods in this object. Allows subclasses to do some additional initialization actions.
    • isValid

      public final boolean isValid()
      Return true if OK button is valid (enabled), otherwise return false.
      Returns:
      validity status of OK button.
      See Also:
    • setValid

      public final void setValid(boolean newValid)
      Set validity of OK button.
      Parameters:
      newValid - validity status of OK button
      See Also:
    • setMessage

      public void setMessage(Object newMessage)
      Define a descriptive message to be reported. In the most common usage, the message is just a String. However, the type of this parameter is actually Object. Its interpretation depends on its type:
      Object[]
      A recursively interpreted series of messages.
      Component
      The Component is displayed in the dialog.
      Icon
      The Icon is wrapped in a JLabel and displayed in the dialog.
      anything else
      The string representation of the object.
      Parameters:
      newMessage - the Object to report
      See Also:
    • getMessage

      public Object getMessage()
      Get the message object.
      Returns:
      the Object that is to be reported
      See Also:
    • setMessageType

      public void setMessageType(int newType)
      Define the style of the message. The look and feel manager may lay out the dialog differently depending on this value, and will often provide a default icon. The possible values are:
      Parameters:
      newType - the kind of message
      See Also:
    • getMessageType

      public int getMessageType()
      Get the message type.
      Returns:
      the message type
      See Also:
    • setOptionType

      public void setOptionType(int newType)
      Define the set of options. The option type is used by the look and feel to determine what options to show (unless explicit options are supplied):
      Parameters:
      newType - the options the look and feel is to display
      See Also:
    • getOptionType

      public int getOptionType()
      Get the type of options that are to be displayed.
      Returns:
      the option type
      See Also:
    • setOptions

      public void setOptions(Object[] newOptions)
      Define an explicit description of the set of user-selectable options. The usual value for the options parameter is an array of Strings. But the parameter type is an array of Objects. Its interpretation depends on its type:
      Component
      The component is added to the button row directly.
      Icon
      A JButton is created with this icon as its label.
      anything else
      The Object is converted to a string and the result is used to label a JButton.
      Parameters:
      newOptions - an array of user-selectable options
      See Also:
    • getOptions

      public Object[] getOptions()
      Get the explicit choices the user can make.
      Returns:
      the array of Objects that give the user's choices
      See Also:
    • setAdditionalOptions

      public void setAdditionalOptions(Object[] newOptions)
      Define an explicit description of the set of additional user-selectable options. Additional options are supposed to be used for help button, etc.

      The usual value for the options parameter is an array of Strings. But the parameter type is an array of Objects. Its interpretation depends on its type:

      Component
      The component is added to the button row directly.
      Icon
      A JButton is created with this icon as its label.
      anything else
      The Object is converted to a string and the result is used to label a JButton.
      Parameters:
      newOptions - an array of user-selectable options
      See Also:
    • getAdditionalOptions

      public Object[] getAdditionalOptions()
      Get the explicit additional choices the user can make.
      Returns:
      the array of Objects that give the user's choices
      See Also:
    • setValue

      public void setValue(Object newValue)
      Set the value the user has chosen and fires appropriate property change. You probably do not want to call this yourself, of course.
      Parameters:
      newValue - the chosen value
      See Also:
    • getValue

      public Object getValue()
      Get the value the user has selected.
      Returns:
      an Object indicating the option selected by the user
      See Also:
    • getDefaultValue

      public Object getDefaultValue()
      Get the default value of descriptor.
      Returns:
      an Object that represents the default value
      Since:
      5.9
    • setTitle

      public void setTitle(String newTitle)
      Set the title string for this report description.
      Parameters:
      newTitle - the title of this description
      See Also:
    • getTitle

      public String getTitle()
      Get the title string for this report description.
      Returns:
      the title of this description
      See Also:
    • createNotificationLineSupport

      public final NotificationLineSupport createNotificationLineSupport()
      Create NotificationLineSupport if you want to notify users using info/warning/error messages in designed line at the bottom of your dialog. These message will be labelled with appropriate icons.
      Note: Call this method before you call DialogDisplayer.createDialog(DialogDescriptor)
      Returns:
      NotificationLineSupport
      Since:
      7.10
    • getNotificationLineSupport

      public final NotificationLineSupport getNotificationLineSupport()
      Returns NotificationLineSupport if it was created or null if doesn't.
      Note: NotificationLineSupport will not be created by default, API client has to create this support purposely with the exception WizardDescriptor which has such capability longer.
      Returns:
      NotificationLineSupport or null if was not created yet
      Since:
      7.10
      See Also:
    • addPropertyChangeListener

      public void addPropertyChangeListener(PropertyChangeListener listener)
      Add a PropertyChangeListener to the listener list.
      Parameters:
      listener - the PropertyChangeListener to be added
    • removePropertyChangeListener

      public void removePropertyChangeListener(PropertyChangeListener listener)
      Remove a PropertyChangeListener from the listener list.
      Parameters:
      listener - the PropertyChangeListener to be removed
    • firePropertyChange

      protected void firePropertyChange(String propertyName, Object oldValue, Object newValue)
      Fire a PropertyChangeEvent to each listener.
      Parameters:
      propertyName - the programmatic name of the property that was changed
      oldValue - the old value of the property
      newValue - the new value of the property
    • setNoDefaultClose

      public void setNoDefaultClose(boolean noDefaultClose)
      Disable or enabled the closing of dialog window using ESC and the close button in dialog's title bar.
      Parameters:
      noDefaultClose - True to disabled ESC closing and to disable the close button in dialog's title bar.
      Since:
      7.35
      See Also:
    • isNoDefaultClose

      public boolean isNoDefaultClose()
      Returns:
      True if ESC key closing and close button in dialog's title bar are disabled, false otherwise.
      Since:
      7.35
    • getTitleForType

      protected static String getTitleForType(int messageType)
      Get the title to use for the indicated type.
      Parameters:
      messageType - the type of message
      Returns:
      the title to use