站内搜索: 请输入搜索关键词
当前页面: 在线文档首页 > NetBeans API Javadoc 4.1.0

NotifyDescriptor (NetBeans APIs) - NetBeans API Javadoc 4.1.0


org.openide
Class NotifyDescriptor

java.lang.Object
  extended byorg.openide.NotifyDescriptor
Direct Known Subclasses:
DialogDescriptor, NotifyDescriptor.Confirmation, NotifyDescriptor.InputLine, NotifyDescriptor.Message

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:
DialogDisplayer.notify(org.openide.NotifyDescriptor)

Nested Class Summary
static class NotifyDescriptor.Confirmation
          Provides a description of a possible action and requests confirmation from the user before proceeding.
static class NotifyDescriptor.Exception
          Deprecated. Better to use ErrorManager.notify(int, java.lang.Throwable).
static class NotifyDescriptor.InputLine
          Notification providing for a line of text input.
static class NotifyDescriptor.Message
          Provides information about the results of a command.
 
Field Summary
static Object CANCEL_OPTION
          Return value if CANCEL is chosen.
static Object CLOSED_OPTION
          Return value if user closes the window without pressing any button.
static int DEFAULT_OPTION
          Option type used by default.
static int ERROR_MESSAGE
          Message type for error messages.
static int INFORMATION_MESSAGE
          Message type for information messages.
static Object NO_OPTION
          Return value if NO is chosen.
static int OK_CANCEL_OPTION
          Option type used for cancellable confirmations.
static Object OK_OPTION
          Return value if OK is chosen.
static int PLAIN_MESSAGE
          Plain message type using no icon.
static String PROP_DETAIL
          Name of property for the detail message reported.
static String PROP_MESSAGE
          Name of property for the message to be displayed.
static String PROP_MESSAGE_TYPE
          Name of property for the type of message to use.
static String PROP_OPTION_TYPE
          Name of property for the style of options available.
static String PROP_OPTIONS
          Name of property for the exact list of options.
static String PROP_TITLE
          Name of property for the dialog title.
static String PROP_VALID
          Name of property for the OK button validation.
static String PROP_VALUE
          Name of property for the value the user selected.
static int QUESTION_MESSAGE
          Message type for questions.
static int WARNING_MESSAGE
          Message type for warning messages.
static int YES_NO_CANCEL_OPTION
          Option type used for negatable and cancellable confirmations.
static int YES_NO_OPTION
          Option type used for negatable confirmations.
static Object YES_OPTION
          Return value if YES is chosen.
 
Constructor Summary
NotifyDescriptor(Object message, String title, int optionType, int messageType, Object[] options, Object initialValue)
          Creates a new notify descriptor with specified information to report.
 
Method Summary
 void addPropertyChangeListener(PropertyChangeListener listener)
          Add a PropertyChangeListener to the listener list.
protected  void firePropertyChange(String propertyName, Object oldValue, Object newValue)
          Fire a PropertyChangeEvent to each listener.
 Object[] getAdditionalOptions()
          Get the explicit additional choices the user can make.
 Object getDefaultValue()
          Get the default value of descriptor.
 Object getMessage()
          Get the message object.
 int getMessageType()
          Get the message type.
 Object[] getOptions()
          Get the explicit choices the user can make.
 int getOptionType()
          Get the type of options that are to be displayed.
 String getTitle()
          Get the title string for this report description.
protected static String getTitleForType(int messageType)
          Get the title to use for the indicated type.
 Object getValue()
          Get the value the user has selected.
protected  void initialize()
          Method that is called before a value is returned from any of getter methods in this object.
 boolean isValid()
          Return true if OK button is valid (enabled), otherwise return false.
 void removePropertyChangeListener(PropertyChangeListener listener)
          Remove a PropertyChangeListener from the listener list.
 void setAdditionalOptions(Object[] newOptions)
          Define an explicit description of the set of additional user-selectable options.
 void setMessage(Object newMessage)
          Define a descriptive message to be reported.
 void setMessageType(int newType)
          Define the style of the message.
 void setOptions(Object[] newOptions)
          Define an explicit description of the set of user-selectable options.
 void setOptionType(int newType)
          Define the set of options.
 void setTitle(String newTitle)
          Set the title string for this report description.
 void setValid(boolean newValid)
          Set validity of OK button.
 void setValue(Object newValue)
          Set the value the user has chosen and fires appropriate property change.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

PROP_MESSAGE

public static final String PROP_MESSAGE
Name of property for the message to be displayed.

See Also:
Constant Field Values

PROP_MESSAGE_TYPE

public static final String PROP_MESSAGE_TYPE
Name of property for the type of message to use.

See Also:
Constant Field Values

PROP_OPTION_TYPE

public static final String PROP_OPTION_TYPE
Name of property for the style of options available.

See Also:
Constant Field Values

PROP_OPTIONS

public static final String PROP_OPTIONS
Name of property for the exact list of options.

See Also:
Constant Field Values

PROP_VALUE

public static final String PROP_VALUE
Name of property for the value the user selected.

See Also:
Constant Field Values

PROP_TITLE

public static final String PROP_TITLE
Name of property for the dialog title.

See Also:
Constant Field Values

PROP_DETAIL

public static final String PROP_DETAIL
Name of property for the detail message reported.

See Also:
Constant Field Values

PROP_VALID

public static final String PROP_VALID
Name of property for the OK button validation.

See Also:
Constant Field Values

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:
Constant Field Values

YES_NO_OPTION

public static final int YES_NO_OPTION
Option type used for negatable confirmations.

See Also:
Constant Field Values

YES_NO_CANCEL_OPTION

public static final int YES_NO_CANCEL_OPTION
Option type used for negatable and cancellable confirmations.

See Also:
Constant Field Values

OK_CANCEL_OPTION

public static final int OK_CANCEL_OPTION
Option type used for cancellable confirmations.

See Also:
Constant Field Values

ERROR_MESSAGE

public static final int ERROR_MESSAGE
Message type for error messages.

See Also:
Constant Field Values

INFORMATION_MESSAGE

public static final int INFORMATION_MESSAGE
Message type for information messages.

See Also:
Constant Field Values

WARNING_MESSAGE

public static final int WARNING_MESSAGE
Message type for warning messages.

See Also:
Constant Field Values

QUESTION_MESSAGE

public static final int QUESTION_MESSAGE
Message type for questions.

See Also:
Constant Field Values

PLAIN_MESSAGE

public static final int PLAIN_MESSAGE
Plain message type using no icon.

See Also:
Constant Field Values
Constructor Detail

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:
getMessage(), getMessageType(), getOptions(), getOptionType(), getValue()
Method Detail

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(boolean)

setValid

public final void setValid(boolean newValid)
Set validity of OK button.

Parameters:
newValid - validity status of OK button
See Also:
isValid()

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()

getMessage

public Object getMessage()
Get the message object.

Returns:
the Object that is to be reported
See Also:
setMessage(java.lang.Object)

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()

getMessageType

public int getMessageType()
Get the message type.

Returns:
the message type
See Also:
setMessageType(int)

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(), setOptions(java.lang.Object[])

getOptionType

public int getOptionType()
Get the type of options that are to be displayed.

Returns:
the option type
See Also:
setOptionType(int)

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()

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:
setOptions(java.lang.Object[])

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:
getOptions()

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:
setOptions(java.lang.Object[])

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()

getValue

public Object getValue()
Get the value the user has selected.

Returns:
an Object indicating the option selected by the user
See Also:
setValue(java.lang.Object)

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()

getTitle

public String getTitle()
Get the title string for this report description.

Returns:
the title of this description
See Also:
setTitle(java.lang.String)

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

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


Built on May 4 2005.  |  Portions Copyright 1997-2005 Sun Microsystems, Inc. All rights reserved.