BiOptionPane

This class is used to layout default dialog controls. Normally this class is not used directly but one of the static methods are used to create new dialogs.

This class extends BiComponent and therefore all methods and fields available for BiComponent are also available for BiOptionPane .

Constructor

new BiOptionPane ( oMessage [ ,sMessageType [ ,sOptionType [ ,oImage [ ,oOptions [ ,oInitialValue ] ] ] ] ] )

Parameters

NameTypeOptionalDefaultDescripton
oMessageObjectThe text or BiComponent to show as a message inside the dialog
sMessageTypeStringcheckedplain The type of the message that is shown. This sets the image on the option pane if no other image is provided. Valid values are:

plain - No image
error - Shows a stop (x) image
information - Shows an image with an 'i' on
warning - Shows an image with an exclamation mark on
question - Show a question mark image
sOptionTypeStringcheckeddefault The option type describes what buttons to show on the optinon pane. This is ignored if the options are set. Valid values are:

default - Usually shows an "OK" button
yesno - Shows a "Yes" and a "No" button
yesnocancel - Shows three buttons with the text "Yes", "No" and "Cancel"
okcancel - Shows an "OK" and a "Cancel" button
oImageBiImagecheckedThe image to show on the option pane. If left out then the image defined by the messageType is used.
oOptionsObject[]checkedThis describes what options/buttons to show on the option pane. This is an array of objects and if the object is a BiComponent then it is added as it is. If not, a new button is created where the text is taken by using the toString method on the object.
oInitialValueObjectcheckedThis is used to define which of the options that should be treated as the default acceptButton

Properties

NameTypegetsetDescripton
acceptButtonBiEventTargetcheckedcheckedThe button that acts as the default accept button. If this is set then the action event is dispatched from the accept button when the enter key is pressed. This does not have to be a BiButton, any BiEventTarget will work.
cancelButtonBiEventTargetcheckedcheckedThe button that acts as the default cancel button. If this is set then the action event is dispatched from the cancel button. This does not have to be a BiButton, any BiEventTarget will work.
dialogBiDialogcheckedIf a dialog has been created from the option pane then this points to that dialog.
imageBiImagecheckedThe image that is shown on the option pane.
initialValueObjectcheckedcheckedThis is used to define which of the options that should be treated as the default acceptButton.
inputComponentBiComponentcheckedcheckedThis allows an input component to be shown below the message component. This is created when creating input dialogs.
messageObjectcheckedThe object used to show the message on the dialog. If the message is a BiComponent then it is shown as it is, otherwise a BiLabel is created using the message toString as the text.
messageTypeStringcheckedThe type of the message that is shown. This sets the image on the option pane if no other image is provided. Valif values are:

plain - No image
error - Shows a stop (x) image
information - Shows an image with an 'i' on
warning - Shows an image with an exclamation mark on
question - Show a question mark image
optionsObject[]checkedThis describes what option buttons to show on the option pane. This is an array of objects and if the object is a BiComponent then it is added as it is. If not, a new BiButton is created where the text is taken by using the toString method on the object.
optionTypeStringcheckedThe option type describes what buttons to show on the optinon pane. This is ignored if the options are set. Valid values are:

default - Shows an "OK" button
yesno - Shows a "Yes" and a "No" button
yesnocancel - Shows three buttons with the text "Yes", "No" and "Cancel"
okcancel - Shows an "OK" and a "Cancel" button
stringBundleBiStringBundlecheckedcheckedThe string bundle to use for this option pane. If this is set to null then the static string bundle for BiOptionPane is used
valueObjectcheckedcheckedSets the value of the option pane. This is used as the dialogResult when the option pane is used with a dialog.

Methods

NameDescription
createDialogThis creates a dialog where the option pane is used as the contentPane.

Events

None.

Static Methods

NameDescription
createConfirmDialogCreates a new BiDialog with a option pane as the contentPane of the dialog window.

This dialog is used to ask the user to confirm something. The buttons shown are set by the optionType.

The returnValue for the dialog reflects the button clicked. The values are:

ok - The "OK" button was clicked
cancel - The "Cancel" button was clicked
yes - The "Yes" button was clicked
no - The "No" button was clicked
createInputDialogCreates a new BiDialog with a option pane as the contentPane of the dialog window.

This dialog is used to allow the user to enter a text value. The default text value can be provided using the sDefaultValue argument. The buttons provided for these dialogs are always an "OK" and a "Cancel" button.

The returnValue for the dialog reflects whether the user entered any value and pressed "OK" or pressed "Cancel". The value is null when the user canceled the dialog, otherwise the entered string value is used.
createMessageDialogCreates a new BiDialog with a option pane as the contentPane of the dialog window.

This dialog is used to show a simple message. The iamge can either be set using the option type or by setting using the image argument.

The returnValue for the dialog reflects the button clicked. The values are:

ok - The "OK" button was clicked
cancel - The "Cancel" button was clicked
yes - The "Yes" button was clicked
no - The "No" button was clicked
createOptionDialogCreates a new BiDialog with a option pane as the contentPane of the dialog window.

This dialog is used to show custom option buttons that the user can select between. The options argument should be used to define the buttons to use.

The returnValue for the dialog reflects the button clicked. The value will be the object that the clicked button was created from.
getComponentFromObjectReturns a component from the object. If the object is already a BiComponent then it is returned as it is, otherwise a BiLabel is created where the text on the label is the object toString.
getImageFromOptionTypeReturns the BiImage derived from the option type string argument. Valid values for the argument string are the same as for the optionType property.

Static Fields

NameTypeDescripton
BUTTONS_GAPNumberThe distance between the option buttons
BUTTONS_RESULT_PROPERTYStringThe default property to get the result from the option buttons
BUTTONS_WIDTHNumberThe default width of the option buttons
IMAGE_MESSAGE_GAPNumberThe distance between the message and the image
MESSAGE_BUTTONS_GAPNumberThe distance between the message/input component and the buttons
MESSAGE_INPUT_GAPNumberThe gap distance between the message and the input component
PADDING_BOTTOMNumberThe padding at the bottom edge
PADDING_LEFTNumberThe padding at the left edge
PADDING_RIGHTNumberThe padding at the right edge
PADDING_TOPNumberThe padding at the top edge

Remarks

When creating dialogs, beware that closing the dialog will dispose the option pane. The labels for the buttons are provided by a BiStringBundle and the following keys are used: OptionPaneYes OptionPaneNo OptionPaneOK OptionPaneCancel OptionPaneMessage OptionPaneSelectAnOption OptionPaneInput

Method Details

createDialog

This creates a dialog where the option pane is used as the contentPane.

Syntax

object.createDialog ( [ sCaption ] )

Parameters

NameTypeOptionalDefaultDescripton
sCaptionStringcheckedThe caption text on the dialog window

Return Type

BiDialog

Static Method Details

createConfirmDialog

Creates a new BiDialog with a option pane as the contentPane of the dialog window.

This dialog is used to ask the user to confirm something. The buttons shown are set by the optionType.

The returnValue for the dialog reflects the button clicked. The values are:

ok - The "OK" button was clicked
cancel - The "Cancel" button was clicked
yes - The "Yes" button was clicked
no - The "No" button was clicked

Syntax

BiOptionPane . createConfirmDialog ( oMessage [ ,sCaption [ ,sMessageType [ ,sOptionType [ ,oImage ] ] ] ] )

Parameters

NameTypeOptionalDefaultDescripton
oMessageObjectThe text or BiComponent to show as a message inside the dialog
sCaptionStringcheckedSelect an Option The caption text to show on the dialog window
sMessageTypeStringcheckedquestion The type of the message that is shown. This sets the image on the option pane if no other image is provided. Valid values are:

plain - No image
error - Shows a stop (x) image
information - Shows an image with an 'i' on
warning - Shows an image with an exclamation mark on
question - Show a question mark image
sOptionTypeStringcheckedyesnocancel The option type describes what buttons to show on the optinon pane. This is ignored if the options are set. Valid values are:

default - Usually shows an "OK" button
yesno - Shows a "Yes" and a "No" button
yesnocancel - Shows three buttons with the text "Yes", "No" and "Cancel"
okcancel - Shows an "OK" and a "Cancel" button
oImageBiImagecheckedThe image to show on the option pane. If left out then the image defined by the messageType is used.

Return Type

BiDialog

createInputDialog

Creates a new BiDialog with a option pane as the contentPane of the dialog window.

This dialog is used to allow the user to enter a text value. The default text value can be provided using the sDefaultValue argument. The buttons provided for these dialogs are always an "OK" and a "Cancel" button.

The returnValue for the dialog reflects whether the user entered any value and pressed "OK" or pressed "Cancel". The value is null when the user canceled the dialog, otherwise the entered string value is used.

Syntax

BiOptionPane . createInputDialog ( oMessage [ ,sCaption [ ,sMessageType [ ,oImage,sDefaultValue ] ] ] )

Parameters

NameTypeOptionalDefaultDescripton
oMessageObjectThe text or BiComponent to show as a message inside the dialog
sCaptionStringcheckedInput The caption text to show on the dialog window
sMessageTypeStringcheckedquestion The type of the message that is shown. This sets the image on the option pane if no other image is provided. Valid values are:

plain - No image
error - Shows a stop (x) image
information - Shows an image with an 'i' on
warning - Shows an image with an exclamation mark on
question - Show a question mark image
oImageBiImagecheckedThe image to show on the option pane. If left out then the image defined by the messageType is used.
sDefaultValueStringThe default text to show on the text field

Return Type

BiDialog

createMessageDialog

Creates a new BiDialog with a option pane as the contentPane of the dialog window.

This dialog is used to show a simple message. The iamge can either be set using the option type or by setting using the image argument.

The returnValue for the dialog reflects the button clicked. The values are:

ok - The "OK" button was clicked
cancel - The "Cancel" button was clicked
yes - The "Yes" button was clicked
no - The "No" button was clicked

Syntax

BiOptionPane . createMessageDialog ( oMessage [ ,sCaption [ ,sMessageType [ ,oImage ] ] ] )

Parameters

NameTypeOptionalDefaultDescripton
oMessageObjectThe text or BiComponent to show as a message inside the dialog
sCaptionStringcheckedThe caption text to show on the dialog window
sMessageTypeStringcheckedinformation The type of the message that is shown. This sets the image on the option pane if no other image is provided. Valid values are:

plain - No image
error - Shows a stop (x) image
information - Shows an image with an 'i' on
warning - Shows an image with an exclamation mark on
question - Show a question mark image
oImageBiImagecheckedThe image to show on the option pane. If left out then the image defined by the messageType is used.

Return Type

BiDialog

createOptionDialog

Creates a new BiDialog with a option pane as the contentPane of the dialog window.

This dialog is used to show custom option buttons that the user can select between. The options argument should be used to define the buttons to use.

The returnValue for the dialog reflects the button clicked. The value will be the object that the clicked button was created from.

Syntax

BiOptionPane . createOptionDialog ( oMessage [ ,sCaption [ ,sMessageType,sOptionType [ ,oImage,oOptions,oInitialValue ] ] ] )

Parameters

NameTypeOptionalDefaultDescripton
oMessageObjectThe text or BiComponent to show as a message inside the dialog
sCaptionStringcheckedThe caption text to show on the dialog window
sMessageTypeStringcheckedinformation The type of the message that is shown. This sets the image on the option pane if no other image is provided. Valid values are:

plain - No image
error - Shows a stop (x) image
information - Shows an image with an 'i' on
warning - Shows an image with an exclamation mark on
question - Show a question mark image
sOptionTypeStringThe option type describes what buttons to show on the optinon pane. This is ignored if the options are set. Valid values are:

default - Usually shows an "OK" button
yesno - Shows a "Yes" and a "No" button
yesnocancel - Shows three buttons with the text "Yes", "No" and "Cancel"
okcancel - Shows an "OK" and a "Cancel" button
oImageBiImagecheckedThe image to show on the option pane. If left out then the image defined by the messageType is used.
oOptionsObject[]This describes what options/buttons to show on the option pane. This is an array of objects and if the object is a BiComponent then it is added as it is. If not, a new button is created where the text is taken by using the toString method on the object.
oInitialValueObjectThis is used to define which of the options that should be treated as the default acceptButton

Return Type

BiDialog

getComponentFromObject

Returns a component from the object. If the object is already a BiComponent then it is returned as it is, otherwise a BiLabel is created where the text on the label is the object toString.

Syntax

BiOptionPane . getComponentFromObject ( o )

Parameters

NameTypeOptionalDefaultDescripton
oObjectThe object that is used to return the component.

Return Type

BiComponent

getImageFromOptionType

Returns the BiImage derived from the option type string argument. Valid values for the argument string are the same as for the optionType property.

Syntax

BiOptionPane . getImageFromOptionType ( sOptionType )

Parameters

NameTypeOptionalDefaultDescripton
sOptionTypeStringThe option type string that should define what image to return.

Return Type

BiImage