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
| Name | Type | Optional | Default | Descripton |
oMessage | Object | The text or BiComponent to show as a message inside the dialog | ||
sMessageType | String | ![]() | plain | 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 |
sOptionType | String | ![]() | default | 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 |
oImage | | ![]() | The image to show on the option pane. If left out then the image defined by the messageType is used. | |
oOptions | Object[] | ![]() | 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. | |
oInitialValue | Object | ![]() | This is used to define which of the options that should be treated as the default acceptButton |
Properties
| Name | Type | get | set | Descripton |
acceptButton | | ![]() | ![]() | The 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. |
cancelButton | | ![]() | ![]() | The 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. |
dialog | | ![]() | If a dialog has been created from the option pane then this points to that dialog. | |
image | | ![]() | The image that is shown on the option pane. | |
initialValue | Object | ![]() | ![]() | This is used to define which of the options that should be treated as the default acceptButton. |
inputComponent | | ![]() | ![]() | This allows an input component to be shown below the message component. This is created when creating input dialogs. |
message | Object | ![]() | The 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. | |
messageType | String | ![]() | The 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 | |
options | Object[] | ![]() | This 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. | |
optionType | String | ![]() | The 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 | |
stringBundle | | ![]() | ![]() | The string bundle to use for this option pane. If this is set to null then the static string bundle for BiOptionPane is used |
value | Object | ![]() | ![]() | Sets the value of the option pane. This is used as the dialogResult when the option pane is used with a dialog. |
Methods
| Name | Description |
createDialog | This creates a dialog where the option pane is used as the contentPane. |
Events
None.
Static Methods
| Name | Description |
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 |
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. |
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 |
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. |
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. |
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. |
Static Fields
| Name | Type | Descripton |
BUTTONS_GAP | Number | The distance between the option buttons |
BUTTONS_RESULT_PROPERTY | String | The default property to get the result from the option buttons |
BUTTONS_WIDTH | Number | The default width of the option buttons |
IMAGE_MESSAGE_GAP | Number | The distance between the message and the image |
MESSAGE_BUTTONS_GAP | Number | The distance between the message/input component and the buttons |
MESSAGE_INPUT_GAP | Number | The gap distance between the message and the input component |
PADDING_BOTTOM | Number | The padding at the bottom edge |
PADDING_LEFT | Number | The padding at the left edge |
PADDING_RIGHT | Number | The padding at the right edge |
PADDING_TOP | Number | The 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
| Name | Type | Optional | Default | Descripton |
sCaption | String | ![]() | The caption text on the dialog window |
Return Type
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
| Name | Type | Optional | Default | Descripton |
oMessage | Object | The text or BiComponent to show as a message inside the dialog | ||
sCaption | String | ![]() | Select an Option | The caption text to show on the dialog window |
sMessageType | String | ![]() | question | 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 |
sOptionType | String | ![]() | yesnocancel | 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 |
oImage | | ![]() | The image to show on the option pane. If left out then the image defined by the messageType is used. |
Return Type
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
| Name | Type | Optional | Default | Descripton |
oMessage | Object | The text or BiComponent to show as a message inside the dialog | ||
sCaption | String | ![]() | Input | The caption text to show on the dialog window |
sMessageType | String | ![]() | question | 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 |
oImage | | ![]() | The image to show on the option pane. If left out then the image defined by the messageType is used. | |
sDefaultValue | String | The default text to show on the text field |
Return Type
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
| Name | Type | Optional | Default | Descripton |
oMessage | Object | The text or BiComponent to show as a message inside the dialog | ||
sCaption | String | ![]() | The caption text to show on the dialog window | |
sMessageType | String | ![]() | information | 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 |
oImage | | ![]() | The image to show on the option pane. If left out then the image defined by the messageType is used. |
Return Type
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
| Name | Type | Optional | Default | Descripton |
oMessage | Object | The text or BiComponent to show as a message inside the dialog | ||
sCaption | String | ![]() | The caption text to show on the dialog window | |
sMessageType | String | ![]() | information | 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 |
sOptionType | String | 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 | ||
oImage | | ![]() | The image to show on the option pane. If left out then the image defined by the messageType is used. | |
oOptions | Object[] | 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. | ||
oInitialValue | Object | This is used to define which of the options that should be treated as the default acceptButton |
Return Type
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
| Name | Type | Optional | Default | Descripton |
o | Object | The object that is used to return the component. |
Return Type
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
| Name | Type | Optional | Default | Descripton |
sOptionType | String | The option type string that should define what image to return. |
