buoy.widget
Class BStandardDialog

java.lang.Object
  extended by buoy.widget.BStandardDialog

public class BStandardDialog
extends java.lang.Object

BStandardDialog is used for displaying a variety of "standard" modal dialogs which display messages or ask for simple types of input. Most platforms define a standardized appearance for such dialogs (the layout, the use of particular icons, etc.), and this class will automatically create dialogs which look correct for the current platform.

BStandardDialog does not extend Widget. It is a fully self contained user interface element. You simply create the BStandardDialog and call an appropriate method to display it. That method blocks until the dialog has been dismissed, then returns whatever input was entered by the user.

There are three different methods to show a dialog, which correspond to the three major types of dialog which can be shown:

BStandardDialog allows you to specify a message to be displayed in the dialog. Usually this is a String, but it can be other types of object as well. BStandardDialog allows you to specify a style, which may be any of the following values: ERROR, INFORMATION, WARNING, QUESTION, or PLAIN. This determines which of the platform-specific standard icons will appear in the dialog.

Author:
Peter Eastman

Nested Class Summary
static class BStandardDialog.Style
          This inner class represents a style for the dialog.
 
Field Summary
static BStandardDialog.Style ERROR
           
static BStandardDialog.Style INFORMATION
           
static BStandardDialog.Style PLAIN
           
static BStandardDialog.Style QUESTION
           
static BStandardDialog.Style WARNING
           
 
Constructor Summary
BStandardDialog()
          Create a new BStandardDialog with no message whose style is PLAIN.
BStandardDialog(java.lang.String title, java.lang.Object message, BStandardDialog.Style style)
          Create a new BStandardDialog.
 
Method Summary
 java.lang.Object getMessage()
          Get the message displayed in the dialog.
 BStandardDialog.Style getStyle()
          Get the style of the dialog.
 java.lang.String getTitle()
          Get the title displayed on the dialog.
 void setMessage(java.lang.Object message)
          Set the message displayed in the dialog.
 void setStyle(BStandardDialog.Style style)
          Set the style of the dialog.
 void setTitle(java.lang.String title)
          Set the title displayed on the dialog.
 java.lang.String showInputDialog(Widget parent, java.lang.String[] options, java.lang.String defaultVal)
          Show a dialog which contains the message and space for the user to enter value.
 void showMessageDialog(Widget parent)
          Show a dialog which contains the message.
 int showOptionDialog(Widget parent, java.lang.String[] options, java.lang.String defaultVal)
          Show a dialog which contains the message and two or three buttons to choose from.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

ERROR

public static final BStandardDialog.Style ERROR

INFORMATION

public static final BStandardDialog.Style INFORMATION

WARNING

public static final BStandardDialog.Style WARNING

QUESTION

public static final BStandardDialog.Style QUESTION

PLAIN

public static final BStandardDialog.Style PLAIN
Constructor Detail

BStandardDialog

public BStandardDialog()
Create a new BStandardDialog with no message whose style is PLAIN.


BStandardDialog

public BStandardDialog(java.lang.String title,
                       java.lang.Object message,
                       BStandardDialog.Style style)
Create a new BStandardDialog.

Parameters:
title - the title to display on the dialog
message - the message to display inside the dialog
style - the style of the dialog to display
Method Detail

getTitle

public java.lang.String getTitle()
Get the title displayed on the dialog.


setTitle

public void setTitle(java.lang.String title)
Set the title displayed on the dialog.


getMessage

public java.lang.Object getMessage()
Get the message displayed in the dialog.


setMessage

public void setMessage(java.lang.Object message)
Set the message displayed in the dialog.


getStyle

public BStandardDialog.Style getStyle()
Get the style of the dialog.


setStyle

public void setStyle(BStandardDialog.Style style)
Set the style of the dialog.


showMessageDialog

public void showMessageDialog(Widget parent)
Show a dialog which contains the message. This method blocks until the user clicks "OK", dismissing the dialog.

Parameters:
parent - the dialog's parent Widget (usually a WindowWidget). This may be null.

showOptionDialog

public int showOptionDialog(Widget parent,
                            java.lang.String[] options,
                            java.lang.String defaultVal)
Show a dialog which contains the message and two or three buttons to choose from. This method blocks until the user clicks one of the buttons, dismissing the dialog.

Parameters:
parent - the dialog's parent Widget (usually a WindowWidget). This may be null.
options - the list of labels to display on the buttons. This must be of length 2 or 3.
defaultVal - the option which should be shown as the default value
Returns:
the index of the button selected by the user

showInputDialog

public java.lang.String showInputDialog(Widget parent,
                                        java.lang.String[] options,
                                        java.lang.String defaultVal)
Show a dialog which contains the message and space for the user to enter value. The interface for entering the value is platform specific, but it will usually be a text field, list, or combo box. This method blocks until the user clicks "OK" or "Cancel", dismissing the dialog.

Parameters:
parent - the dialog's parent Widget (usually a WindowWidget). This may be null.
options - the list of allowed values. This may be null, in which case the user is free to enter any value.
defaultVal - the default value when the dialog first appears
Returns:
the value entered by the user, or null if they clicked "Cancel"


Written by Peter Eastman.