Class DialogDescriptor

java.lang.Object
org.openide.NotifyDescriptor
org.openide.DialogDescriptor
All Implemented Interfaces:
org.openide.util.HelpCtx.Provider
Direct Known Subclasses:
WizardDescriptor

public class DialogDescriptor extends NotifyDescriptor implements org.openide.util.HelpCtx.Provider
A description of a standard dialog. It may be built later using DialogDisplayer.createDialog(org.openide.DialogDescriptor) or shown with DialogDisplayer.notify(org.openide.NotifyDescriptor). It extends NotifyDescriptor's capabilities by allowing specification of the modal/nonmodal state of the dialog, button behavior and alignment, help, and a listener on button presses. Anyone who wants to display some kind of dialog with standard behavior should use this class to describe it and use createDialog(d) to build it. When the dialog is closed you may use NotifyDescriptor.getValue() to determine which button closed it.

The property message (inherited from NotifyDescriptor) is primarily used here to specify the inner GUI component of the dialog, in contrast to NotifyDescriptor which generally uses a String message.

If you want to set one of the custom Options to be the default Option, it is possible to call DialogDescriptor.setValue(the button you want to have default...)

  • Field Details

    • PROP_OPTIONS_ALIGN

      public static final String PROP_OPTIONS_ALIGN
      Name of property for alignment of options.
      See Also:
    • PROP_MODAL

      public static final String PROP_MODAL
      Name of property for modality of dialog.
      See Also:
    • PROP_LEAF

      public static final String PROP_LEAF
      Name of property whether the dialg is leaf or can be the owner of other one dialog.
      See Also:
    • PROP_HELP_CTX

      public static final String PROP_HELP_CTX
      Name of property for the help context.
      See Also:
    • PROP_BUTTON_LISTENER

      public static final String PROP_BUTTON_LISTENER
      Name of property for the button listener.
      See Also:
    • PROP_CLOSING_OPTIONS

      public static final String PROP_CLOSING_OPTIONS
      Name of property for list of closing options.
      See Also:
    • BOTTOM_ALIGN

      public static final int BOTTOM_ALIGN
      See Also:
    • RIGHT_ALIGN

      public static final int RIGHT_ALIGN
      Alignment to place options vertically in the right part.
      See Also:
    • DEFAULT_ALIGN

      public static final int DEFAULT_ALIGN
      Alignment to place options in the default manner.
      See Also:
  • Constructor Details

    • DialogDescriptor

      public DialogDescriptor(Object innerPane, String title)
      Create modal dialog descriptor with given title and inner part, with OK/Cancel buttons with default alignment, no help available. All buttons will close the dialog and the getValue () will provide the pressed option.
      Parameters:
      innerPane - inner component of the dialog, or String message
      title - title of the dialog
    • DialogDescriptor

      public DialogDescriptor(Object innerPane, String title, boolean isModal, ActionListener bl)
      Create dialog descriptor with given title, inner part and modal status, with OK/Cancel buttons displayed with default alignment, no help available. If bl is not null, then it will receive notifications when the user presses the buttons. (If no listener is specified, it's still possible to retrieve the user-selected button using NotifyDescriptor.getValue().)
      Parameters:
      innerPane - inner component of the dialog, or String message
      title - title of the dialog
      isModal - modal status
      bl - listener for user's button presses
    • DialogDescriptor

      public DialogDescriptor(Object innerPane, String title, boolean isModal, int optionType, Object initialValue, ActionListener bl)
      Create dialog descriptor with given title, inner part, modal status, option type and default option. Options have default alignment, no help available. If the action listener is null, all option buttons will close the dialog and the getValue () will provide the pressed option.
      Parameters:
      innerPane - inner component of the dialog, or String message
      title - title of the dialog
      isModal - modal status
      optionType - one of the standard options (OK_CANCEL_OPTION, ...)
      initialValue - default option (default button)
      bl - listener for the user's button presses or null for default close action on all options
    • DialogDescriptor

      public DialogDescriptor(Object innerPane, String title, boolean modal, Object[] options, Object initialValue, int optionsAlign, org.openide.util.HelpCtx helpCtx, ActionListener bl)
      Create dialog descriptor; possibility of specifying custom array of options and their alignment. If the action listener is null, all option buttons will close the dialog and the getValue () will provide the pressed option. When a custom option set is provided, if any of the standard options (OK_OPTION, CLOSE_OPTION or CANCEL_OPTION) are used, the dialog will close when a button for a standard option is pressed; otherwise for custom options, closing the dialog is left to the ActionListener or setClosingOptions.
      Parameters:
      innerPane - inner component of the dialog, or String message
      title - title of the dialog
      modal - modal status
      options - array of custom options (null means no options at all); may include strings (for button labels; such buttons then do nothing by default) or components (such as buttons, in which case you are responsible for listening to the buttons yourself)
      initialValue - default option from custom option array
      optionsAlign - specifies where to place options in the dialog
      helpCtx - help context specifying help page
      bl - listener for the user's button presses or null for default close action on all options (unless you specified the options yourself)
      See Also:
    • DialogDescriptor

      public DialogDescriptor(Object innerPane, String title, boolean modal, Object[] options, Object initialValue, int optionsAlign, org.openide.util.HelpCtx helpCtx, ActionListener bl, boolean leaf)
      Create dialog descriptor; possibility of specifying custom array of options and their alignment. If the action listener is null, all option buttons will close the dialog and the getValue () will provide the pressed option. When a custom option set is provided, if any of the standard options (OK_OPTION, CLOSE_OPTION or CANCEL_OPTION) are used, the dialog will close when a button for a standard option is pressed; otherwise for custom options, closing the dialog is left to the ActionListener or setClosingOptions.
      Parameters:
      innerPane - inner component of the dialog, or String message
      title - title of the dialog
      modal - modal status
      options - array of custom options (null means no options at all); may include strings (for button labels; such buttons then do nothing by default) or components (such as buttons, in which case you are responsible for listening to the buttons yourself)
      initialValue - default option from custom option array
      optionsAlign - specifies where to place options in the dialog
      helpCtx - help context specifying help page
      bl - listener for the user's button presses or null for default close action on all options (unless you specified the options yourself)
      leaf - property specifies whether the dialog can be owner of other dialogs
      Since:
      5.5
      See Also:
    • DialogDescriptor

      public DialogDescriptor(Object innerPane, String title, boolean isModal, int optionType, Object initialValue, int optionsAlign, org.openide.util.HelpCtx helpCtx, ActionListener bl)
      Create dialog descriptor. If the action listener is null, all option buttons will close the dialog and the getValue () will provide the pressed option.
      Parameters:
      innerPane - inner component of the dialog, or String message
      title - title of the dialog
      isModal - modal status
      optionType - one of the standard options (OK_CANCEL_OPTION, ...)
      initialValue - default option (default button)
      optionsAlign - specifies where to place options in the dialog
      helpCtx - help context specifying help page
      bl - listener for the user's button presses or null for default close action on all options (unless you specified the options yourself)
  • Method Details

    • getOptionsAlign

      public int getOptionsAlign()
      Get current option alignment.
      Returns:
      current option alignment
      See Also:
    • setOptionsAlign

      public void setOptionsAlign(int optionsAlign)
      Set new option alignment. See aligment constants for possible values. Fires property change event if successful.
      Parameters:
      optionsAlign - new options alignment
      Throws:
      IllegalArgumentException - when unknown alignment is given
      See Also:
    • isModal

      public boolean isModal()
      Get modal status.
      Returns:
      modal status
      See Also:
    • setModal

      public void setModal(boolean modal)
      Set new modal status. Fires property change event if successful.
      Parameters:
      modal - new modal status
      See Also:
    • isLeaf

      public boolean isLeaf()
      Get leaf status. If is leaf then cannot be the owner to other one dialog.
      Returns:
      leaf status
      Since:
      5.5
      See Also:
    • setLeaf

      public void setLeaf(boolean leaf)
      Set new leaf status. Fires property change event if successful.
      Parameters:
      leaf - new leaf status
      Since:
      5.5
      See Also:
    • setClosingOptions

      public void setClosingOptions(Object[] arr)
      Setter for list of options that close the dialog. Special values are:
      • null - all options will close the dialog
      • empty array - no option will close the dialog
      Parameters:
      arr - array of options that should close the dialog when pressed if null then all options close the dialog
    • getClosingOptions

      public Object[] getClosingOptions()
      Getter for list of closing options.
      Returns:
      array of options or null
    • getHelpCtx

      public org.openide.util.HelpCtx getHelpCtx()
      Get current help context asociated with this dialog descriptor.
      Specified by:
      getHelpCtx in interface org.openide.util.HelpCtx.Provider
      Returns:
      current help context
      See Also:
    • setHelpCtx

      public void setHelpCtx(org.openide.util.HelpCtx helpCtx)
      Set new help context for this dialog descriptor. Fires property change event if successful.

      The implementation should automatically display a help button among the secondary options, without your needing to specify it, if the help context on the descriptor is neither null nor HelpCtx.DEFAULT_HELP. If the descriptor is null, this feature will be disabled (you can still add your own help button manually if you wish, of course). If DEFAULT_HELP (the default), normally the button will also be disabled, however if the inner pane is a component and this component has an associated help ID, that will be used automatically. So most users should never need to manually add a help button: call this method with the correct context, or associate an ID with the displayed component. Note that to set it to null you must explicitly call this method; passing null in the constructor actually sets it to DEFAULT_HELP.

      Parameters:
      helpCtx - new help context, can be null (no help)
      See Also:
    • getButtonListener

      public ActionListener getButtonListener()
      Get button listener which listens for the user's button presses.
      Returns:
      current button listener instance or null
      See Also:
    • setButtonListener

      public void setButtonListener(ActionListener l)
      Set new button listener instance for this dialog descriptor. Fires property change event if successful.
      Parameters:
      l - new button listener. It may be null, in which case listening is cancelled.
      See Also: