public class DialogDescriptor extends NotifyDescriptor implements HelpCtx.Provider
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...)
NotifyDescriptor.Confirmation, NotifyDescriptor.Exception, NotifyDescriptor.InputLine, NotifyDescriptor.Message
Modifier and Type | Field and Description |
---|---|
static int |
BOTTOM_ALIGN |
static int |
DEFAULT_ALIGN
Alignment to place options in the default manner.
|
static String |
PROP_BUTTON_LISTENER
Name of property for the button listener.
|
static String |
PROP_CLOSING_OPTIONS
Name of property for list of closing options.
|
static String |
PROP_HELP_CTX
Name of property for the help context.
|
static String |
PROP_LEAF
Name of property whether the dialg is leaf or can be the owner of other one dialog.
|
static String |
PROP_MODAL
Name of property for modality of dialog.
|
static String |
PROP_OPTIONS_ALIGN
Name of property for alignment of options.
|
static int |
RIGHT_ALIGN
Alignment to place options vertically
in the right part.
|
CANCEL_OPTION, CLOSED_OPTION, DEFAULT_OPTION, ERROR_MESSAGE, INFORMATION_MESSAGE, NO_OPTION, OK_CANCEL_OPTION, OK_OPTION, PLAIN_MESSAGE, PROP_DETAIL, PROP_ERROR_NOTIFICATION, PROP_INFO_NOTIFICATION, PROP_MESSAGE, PROP_MESSAGE_TYPE, PROP_NO_DEFAULT_CLOSE, PROP_OPTION_TYPE, PROP_OPTIONS, PROP_TITLE, PROP_VALID, PROP_VALUE, PROP_WARNING_NOTIFICATION, QUESTION_MESSAGE, WARNING_MESSAGE, YES_NO_CANCEL_OPTION, YES_NO_OPTION, YES_OPTION
Constructor and Description |
---|
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.
|
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.
|
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.
|
DialogDescriptor(Object innerPane,
String title,
boolean isModal,
int optionType,
Object initialValue,
int optionsAlign,
HelpCtx helpCtx,
ActionListener bl)
Create dialog descriptor.
|
DialogDescriptor(Object innerPane,
String title,
boolean modal,
Object[] options,
Object initialValue,
int optionsAlign,
HelpCtx helpCtx,
ActionListener bl)
Create dialog descriptor; possibility of specifying custom
array of options and their alignment.
|
DialogDescriptor(Object innerPane,
String title,
boolean modal,
Object[] options,
Object initialValue,
int optionsAlign,
HelpCtx helpCtx,
ActionListener bl,
boolean leaf)
Create dialog descriptor; possibility of specifying custom
array of options and their alignment.
|
Modifier and Type | Method and Description |
---|---|
ActionListener |
getButtonListener()
Get button listener which listens for the user's button presses.
|
Object[] |
getClosingOptions()
Getter for list of closing options.
|
HelpCtx |
getHelpCtx()
Get current help context asociated with this dialog
descriptor.
|
int |
getOptionsAlign()
Get current option alignment.
|
boolean |
isLeaf()
Get leaf status.
|
boolean |
isModal()
Get modal status.
|
void |
setButtonListener(ActionListener l)
Set new button listener instance for this dialog descriptor.
|
void |
setClosingOptions(Object[] arr)
Setter for list of options that close the dialog.
|
void |
setHelpCtx(HelpCtx helpCtx)
Set new help context for this dialog descriptor.
|
void |
setLeaf(boolean leaf)
Set new leaf status.
|
void |
setModal(boolean modal)
Set new modal status.
|
void |
setOptionsAlign(int optionsAlign)
Set new option alignment.
|
addPropertyChangeListener, createNotificationLineSupport, firePropertyChange, getAdditionalOptions, getDefaultValue, getMessage, getMessageType, getNotificationLineSupport, getOptions, getOptionType, getTitle, getTitleForType, getValue, initialize, isNoDefaultClose, isValid, removePropertyChangeListener, setAdditionalOptions, setMessage, setMessageType, setNoDefaultClose, setOptions, setOptionType, setTitle, setValid, setValue
public static final String PROP_OPTIONS_ALIGN
public static final String PROP_MODAL
public static final String PROP_LEAF
public static final String PROP_HELP_CTX
public static final String PROP_BUTTON_LISTENER
public static final String PROP_CLOSING_OPTIONS
public static final int BOTTOM_ALIGN
public static final int RIGHT_ALIGN
public static final int DEFAULT_ALIGN
public DialogDescriptor(Object innerPane, String title)
innerPane
- inner component of the dialog, or String messagetitle
- title of the dialogpublic DialogDescriptor(Object innerPane, String title, boolean isModal, ActionListener bl)
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()
.)innerPane
- inner component of the dialog, or String messagetitle
- title of the dialogisModal
- modal statusbl
- listener for user's button pressespublic DialogDescriptor(Object innerPane, String title, boolean isModal, int optionType, Object initialValue, ActionListener bl)
innerPane
- inner component of the dialog, or String messagetitle
- title of the dialogisModal
- modal statusoptionType
- 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 optionspublic DialogDescriptor(Object innerPane, String title, boolean modal, Object[] options, Object initialValue, int optionsAlign, HelpCtx helpCtx, ActionListener bl)
ActionListener
or setClosingOptions
.innerPane
- inner component of the dialog, or String messagetitle
- title of the dialogmodal
- modal statusoptions
- 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 arrayoptionsAlign
- specifies where to place
options in the dialoghelpCtx
- help context specifying help pagebl
- listener for the user's button presses or null
for default close action on all options
(unless you specified the options yourself)DialogDescriptor.setClosingOptions(java.lang.Object[])
public DialogDescriptor(Object innerPane, String title, boolean modal, Object[] options, Object initialValue, int optionsAlign, HelpCtx helpCtx, ActionListener bl, boolean leaf)
ActionListener
or setClosingOptions
.innerPane
- inner component of the dialog, or String messagetitle
- title of the dialogmodal
- modal statusoptions
- 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 arrayoptionsAlign
- specifies where to place
options in the dialoghelpCtx
- help context specifying help pagebl
- 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 dialogsDialogDescriptor.setClosingOptions(java.lang.Object[])
public DialogDescriptor(Object innerPane, String title, boolean isModal, int optionType, Object initialValue, int optionsAlign, HelpCtx helpCtx, ActionListener bl)
innerPane
- inner component of the dialog, or String messagetitle
- title of the dialogisModal
- modal statusoptionType
- one of the standard options (OK_CANCEL_OPTION
, ...)initialValue
- default option (default button)optionsAlign
- specifies where to place
options in the dialoghelpCtx
- help context specifying help pagebl
- listener for the user's button presses or null
for default close action on all options
(unless you specified the options yourself)public int getOptionsAlign()
DialogDescriptor.setOptionsAlign(int)
public void setOptionsAlign(int optionsAlign)
optionsAlign
- new options alignmentIllegalArgumentException
- when unknown alignment is givenDialogDescriptor.DEFAULT_ALIGN
public boolean isModal()
DialogDescriptor.setModal(boolean)
public void setModal(boolean modal)
modal
- new modal statusDialogDescriptor.isModal()
public boolean isLeaf()
DialogDescriptor.setLeaf(boolean)
public void setLeaf(boolean leaf)
leaf
- new leaf statusDialogDescriptor.isLeaf()
public void setClosingOptions(Object[] arr)
arr
- array of options that should close the dialog when pressed
if null then all options close the dialogpublic Object[] getClosingOptions()
public HelpCtx getHelpCtx()
getHelpCtx
in interface HelpCtx.Provider
DialogDescriptor.setHelpCtx(org.openide.util.HelpCtx)
public void setHelpCtx(HelpCtx helpCtx)
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
.
helpCtx
- new help context, can be null
(no help)DialogDescriptor.getHelpCtx()
public ActionListener getButtonListener()
DialogDescriptor.setButtonListener(java.awt.event.ActionListener)
public void setButtonListener(ActionListener l)
l
- new button listener. It may be null
, in which case listening is cancelled.DialogDescriptor.getButtonListener()