Developer Documentation
PATH  Mac OS X Documentation > Application Kit Reference: Java


[Previous] [Class List] [Next]

NSAlertPanel


Inherits from: Object
Package: com.apple.yellow.application


Class Description


The objects created by NSAlertPanel are NSPanels (or, in user terminology, dialogs) displayed in modal sessions; they inform users of an event and offer, through buttons, a set of alternatives. The text in these dialogs is localized. The text can be formatted with variable information, using String concatenation. The methods of NSAlertPanel are of two general sorts; one group of methods creates and runs an NSPanel in a modal session for you, while the other group creates and returns an NSPanel object (you must run it in a modal session yourself). For the Yellow Box on Windows, NSAlertPanel provides methods for creating "critical" and "informational" dialogs as well as normal dialogs; these dialogs display the appropriate icons. Because NSAlertPanel is a final class, you cannot sublcass it.


Constants


Constant Type Description
DefaultReturn int The value returned when the first (default) button from the right edge of the NSAlertPanel is clicked.
AlternateReturn int The value returned when the second button from the right edge of the NSAlertPanel is clicked.
OtherReturn int The value returned when the third button from the right edge of the NSAlertPanel is clicked.
ErrorReturn int The value returned if running the NSAlertPanel resulted in an error.

Method Types


Running an alert panel
runAlert
runCriticalAlert
runInformationalAlert
Getting an alert panel
alertPanel
criticalAlertPanel
informationalAlertPanel
releaseAlert

Constructors


NSAlertPanel

public NSRunAlertPanel()

Returns an NSAlertPanel.

alertPanel

public static NSPanel alertPanel(String title, String message, String defaultTitle, String alternateTitle, String otherTitle)

Creates and returns an NSPanel object with the title of title, the text of messge, and buttons with titles of defaultTitle, alternateTitle, and otherTitle. On Windows platforms, the returned object when displayed is a "warning" dialog with the appropriate icon. On Windows, this method centers the buttons in the NSPanel; on other platforms, it lays out the buttons right to left from the lower-right corner of the NSPanel. If the platform is Windows, the application process name is used for the dialog title, regardless of title; if the title is null and the platform is anything else, a default localized title is used. This method creates a button only if the corresponding button title is non-null. You should deallocate objects returned by this method with the releaseAlert method.

See Also: criticalAlertPanel, informationalAlertPanel



criticalAlertPanel

public static NSPanel criticalAlertPanel(String title, String message, String defaultButton, String alternateButton, String otherButton)

Creates and returns an NSPanel object with the title of title, the text of messge, and buttons with titles of defaultTitle, alternateTitle, and otherTitle. On Windows platforms, the returned object is constructed as a "critical" dialog including the appropriate icon. On non-Windows platforms, the NSPanel looks and behaves no differently than a normal alert panel (or dialog). See the description of alertPanel for information on layout and default parameters. You should deallocate objects returned by this method with the releaseAlert method.

See Also: informationalAlertPanel



informationalAlertPanel

public static NSPanel informationalAlertPanel(String title, String message, String defaultButton, String alternateButton, String otherButton)

Creates and returns an NSPanel object with the title of title, the text of messge, and buttons with titles of defaultTitle, alternateTitle, and otherTitle. On Windows platforms, the returned object is constructed as a "critical" dialog including the appropriate icon. On non-Windows platforms, the NSPanel looks and behaves no differently than a normal alert panel (or dialog). See the description of alertPanel for information on layout and default parameters. You should deallocate objects returned by this method with the releaseAlert method.

See Also: criticalAlertPanel



releaseAlert

public static void releaseAlert(NSPanel alertPanel)

Sends autorelease to the delegate of alertPanel.

runAlert

public static int runAlert(String title, String message, String defaultButton, String alternateButton, String otherButton)

Creates and runs an alert panel (or dialog) with the title of title, the text of message, and buttons with titles of defaultTitle, alternateTitle, and otherTitle. On Windows platforms, displays a "warning" dialog with the appropriate icon. This method returns a constant indicating which button was pressed (see the Constants section for details) or ErrorReturn if an error occurred running the modal panel. On Windows platforms, this method centers the buttons in the NSPanel; on other platforms, it lays out the buttons right to left from the lower-right corner of the NSPanel (defaultButton first). If the platform is Windows, the application process name is used for the dialog title, regardless of title. On other platforms, if the title is null or an empty string, a default localized title is used ("Alert" in English). If defaultButton is null or an empty string, a default localized button title ("OK" in English) is used. For the remaining buttons, this method creates them only if their corresponding button title is non-null.

See Also: runCriticalAlert, runInformationalAlert



runCriticalAlert

public static int runCriticalAlert(String title, String message, String defaultButton, String alternateButton, String otherButton)

Creates and runs an alert panel (or dialog) with the title of title, the text of messge, and buttons with titles of defaultTitle, alternateTitle, and otherTitle. On Windows platforms, displays a "critical" dialog with the appropriate icon. On non-Windows platforms, the NSPanel looks and behaves no differently than a normal alert panel (or dialog). See the description of runAlert for information on layout and default parameters.

See Also: runInformationalAlert



runInformationalAlert

public static int runInformationalAlert(String title, String message, String defaultButton, String alternateButton, String otherButton)

Creates and runs an alert panel (or dialog) with the title of title, the text of message, and buttons with titles of defaultTitle, alternateTitle, and otherTitle. On Windows platforms, displays an "information" dialog with the appropriate icon. On non-Windows platforms, the NSPanel looks and behaves no differently than a normal alert panel (or dialog). See the description of runAlert for information on layout and default parameters.

See Also: runCriticalAlert



[Previous] [Next]