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

Table of Contents

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). Because NSAlertPanel is a final class, you cannot subclass 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


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


Constructors



NSAlertPanel

public NSRunAlertPanel()

Returns an NSAlertPanel.


Static Methods



alertPanel

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

Creates and returns an NSPanel object with the title of title, the text of message, and buttons with titles of defaultButton, alternateButton, and otherButton. The buttons are laid out right to left from the lower-right corner of the NSPanel. If title is null a default localized title is used as the dialog title. 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 message, and buttons with titles of defaultButton, alternateButton, and otherButton. 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 message, and buttons with titles of defaultButton, alternateButton, and otherButton. 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 defaultButton, alternateButton, and otherButton. This method returns a constant indicating which button was pressed (see "Constants" for details) or ErrorReturn if an error occurred running the modal panel. The buttons are laid right to left from the lower-right corner of the NSPanel (defaultButton first). If 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 message, and buttons with titles of defaultButton, alternateButton, and otherButton. 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 defaultButton, alternateButton, and otherButton. 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




Table of Contents