buoy.widget
Class BStandardDialog
java.lang.Object
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:
showMessageDialog()
simply displays a
message to the user, and blocks until they click the "OK" button.showOptionDialog()
displays a message
and offers two or three buttons for the user to choose from. It blocks until the user clicks
one of the buttons, then returns the index of the button they selected.showInputDialog()
displays a message
and gives the user space to enter a value. The value may be unrestricted, in which case they
are given a text field to type the value, or it may be restricted to a list of allowed values,
in which case they are given a list or combo box from which to select a value. It blocks until
the user clicks the "OK" or "Cancel" button, then returns the value they entered.
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.
- If it is an Icon, that icon will be displayed.
- If it is a Widget, that Widget will be added to the dialog.
- If it is an array, each element of the array will be displayed on a separate line. This
allows you to display multiple lines of text, or a set of several Widgets.
- All other objects are converted to Strings by calling
toString()
on them.
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.
BStandardDialog
public BStandardDialog()
Create a new BStandardDialog with no message whose style is PLAIN.
BStandardDialog
public BStandardDialog(String title,
Object message,
BStandardDialog.Style style)
Create a new BStandardDialog.
title
- the title to display on the dialogmessage
- the message to display inside the dialogstyle
- the style of the dialog to display
getMessage
public Object getMessage()
Get the message displayed in the dialog.
getTitle
public String getTitle()
Get the title displayed on the dialog.
setMessage
public void setMessage(Object message)
Set the message displayed in the dialog.
setTitle
public void setTitle(String title)
Set the title displayed on the dialog.
showInputDialog
public String showInputDialog(Widget parent,
options[] ,
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.
parent
- the dialog's parent Widget (usually a WindowWidget). This may be null.defaultVal
- the default value when the dialog first appears
- the value entered by the user, or null if they clicked "Cancel"
showMessageDialog
public void showMessageDialog(Widget parent)
Show a dialog which contains the message. This method blocks until the user clicks "OK",
dismissing the dialog.
parent
- the dialog's parent Widget (usually a WindowWidget). This may be null.
showOptionDialog
public int showOptionDialog(Widget parent,
options[] ,
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.
parent
- the dialog's parent Widget (usually a WindowWidget). This may be null.defaultVal
- the option which should be shown as the default value
- the index of the button selected by the user
Written by Peter Eastman.