During the call to the StandardDialog constructor, the following initialization steps will occur:
An OK button, a Cancel button, and a Help button are created
These are the standard buttons used by most dialogs. If the dialog being implemented uses a different set of buttons (for instance, Close, Apply, Next, and so on) the derived class should implement instances of those buttons.
A ButtonPanel containing the OK, Cancel, and Help buttons is created
If the dialog being implemented wants the button panel to contain a different set of buttons, it should call buttonPanel.changeButtons(new Jbutton[] { closeBtn, helpBtn }); // as an example.
A ResourceBundle instance is created
This resource bundle is used to perform localization work within the dialog. It is important to know where the standard dialog looks for the instance of the resource bundle. For example, if the dialog class is MyFunnyDialog, then the resource bundle must be in a file called resources/MyFunnyDialog.properties.
A StandardDialogAdapter is created and is added as a window listener to the dialog
Because of the implementation of the StandardDialogAdapter class, there should never be a reason for a descendant class of StandardDialog to attach a WindowListener to itself. Routing of all window events should be handled by the StandardDialogAdapter. If the descendant class needs to take action when a window close, window open, and so on, event occurs then override the methods in StandardDialog that the StandardDialogAdapter calls. |
Sets the instance of the dialog result to the value passed in, if any
To understand how this works, see Dialog Results.
Sets the dialog’s default close operation to DISPOSE_ON_CLOSE
In most cases, this is the desired behavior; for a dialog that needs a different behavior, this can be changed by the constructor in the descendant class.
Sets the dialog’s content pane layout to be a BoxLayout oriented vertically
Adds entries to the action and input maps of the dialog’s root pane to take a “default action” when the Enter key is pressed by the user
For more information on what this default action is, and why this step is necessary, see the section of this document titled “Dialog default action”.