buoy.widget

Class 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(String title, Object message, BStandardDialog.Style style)
Create a new BStandardDialog.

Method Summary

Object
getMessage()
Get the message displayed in the dialog.
BStandardDialog.Style
getStyle()
Get the style of the dialog.
String
getTitle()
Get the title displayed on the dialog.
void
setMessage(Object message)
Set the message displayed in the dialog.
void
setStyle(BStandardDialog.Style style)
Set the style of the dialog.
void
setTitle(String title)
Set the title displayed on the dialog.
String
showInputDialog(Widget parent, options[] , 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, options[] , String defaultVal)
Show a dialog which contains the message and two or three buttons to choose from.

Field Details

ERROR

public static final BStandardDialog.Style ERROR

INFORMATION

public static final BStandardDialog.Style INFORMATION

PLAIN

public static final BStandardDialog.Style PLAIN

QUESTION

public static final BStandardDialog.Style QUESTION

WARNING

public static final BStandardDialog.Style WARNING

Constructor Details

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.
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 Details

getMessage

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

getStyle

public BStandardDialog.Style getStyle()
Get the style of 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.

setStyle

public void setStyle(BStandardDialog.Style style)
Set the style of 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.
Parameters:
parent - the dialog's parent Widget (usually a WindowWidget). This may be null.
defaultVal - the default value when the dialog first appears
Returns:
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.
Parameters:
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.
Parameters:
parent - the dialog's parent Widget (usually a WindowWidget). This may be null.
defaultVal - the option which should be shown as the default value
Returns:
the index of the button selected by the user

Written by Peter Eastman.