public abstract class AbstractDialog extends Object
AbstractDialog
is the base class for ModalDialog
and ModelessDialog
,
two helper classes used to quickly construct modal and modeless dialogs. The dialogs created with this
class have a unique border and font and a standard button row for the typical buttons like "OK", "Cancel" etc.
Instances of a modal dialog are created with a parent component, a title, the actual dialog content component, and a bit-combination of the standard buttons to be used.
A limited way of input validation is provided by the verifyUserInput
method which can be overridden
in order to return false
if a user input is invalid. In this case the onOK()
,
onYes()
and onNo()
methods are NOT called.
Modifier and Type | Field and Description |
---|---|
static int |
ID_APPLY |
static int |
ID_CANCEL |
static int |
ID_CLOSE |
static int |
ID_HELP |
static int |
ID_NO |
static int |
ID_OK |
static int |
ID_OTHER |
static int |
ID_RESET |
static int |
ID_YES |
Modifier | Constructor and Description |
---|---|
protected |
AbstractDialog(JDialog dialog,
int buttonMask,
Object[] otherButtons,
String helpID) |
Modifier and Type | Method and Description |
---|---|
void |
center()
Centers the dialog within its parent window.
|
abstract void |
close()
This method is called, when the user clicks the close button of the dialog's top window bar.
|
protected void |
collectButtons(List<AbstractButton> buttons)
Called by the constructor in order to initialise the user interface.
|
AbstractButton |
getButton(int buttonID)
Gets the button for the given identifier.
|
int |
getButtonID()
Gets the identifier for the most recently pressed button.
|
int |
getButtonMask()
Gets the button mask passed to the constructor.
|
JPanel |
getButtonPanel() |
Component |
getContent()
Gets the dialog's content component.
|
String |
getHelpID()
Gets the help identifier for the dialog.
|
JDialog |
getJDialog()
Gets the underlying Swing dialog passed to the constructor.
|
Window |
getParent()
Gets the owner of the dialog.
|
protected String |
getQualifiedPropertyName(String name) |
String |
getTitle() |
void |
hide()
Hides the dialog.
|
protected void |
onApply()
Called if the "Apply" button has been clicked.
|
protected void |
onCancel()
Called if the "Cancel" button has been clicked.
|
protected void |
onClose()
Called if the "Close" button has been clicked.
|
protected void |
onHelp()
Called if the help button has been clicked.
|
protected void |
onNo()
Called if the "No" button has been clicked.
|
protected void |
onOK()
Called if the "OK" button has been clicked.
|
protected void |
onOther()
Called if a non-standard button has been clicked.
|
protected void |
onReset()
Called if the reset button has been clicked.
|
protected void |
onYes()
Called if the "Yes" button has been clicked.
|
protected void |
registerButton(int buttonID,
AbstractButton button) |
protected void |
setButtonID(int buttonID)
Sets the identifier for the most recently pressed button.
|
void |
setContent(Component content)
Sets the dialog's content component.
|
void |
setContent(Object content)
Sets the dialog's content.
|
void |
setHelpID(String helpID)
Sets the help identifier for the dialog.
|
void |
setTitle(String title) |
int |
show()
Shows the dialog.
|
static void |
showErrorDialog(Component component,
String message,
String dialogTitle) |
void |
showErrorDialog(String errorMessage)
Shows an error dialog on top of this dialog.
|
void |
showErrorDialog(String message,
String title) |
static void |
showInformationDialog(Component component,
String message,
String dialogTitle) |
void |
showInformationDialog(String infoMessage)
Shows an information dialog on top of this dialog.
|
void |
showInformationDialog(String infoMessage,
String title) |
static void |
showWarningDialog(Component component,
String message,
String dialogTitle) |
void |
showWarningDialog(String warningMessage)
Shows a warning dialog on top of this dialog.
|
void |
showWarningDialog(String warningMessage,
String title) |
protected boolean |
verifyUserInput()
Called in order to perform input validation.
|
public static final int ID_OK
public static final int ID_YES
public static final int ID_NO
public static final int ID_APPLY
public static final int ID_CLOSE
public static final int ID_CANCEL
public static final int ID_RESET
public static final int ID_HELP
public static final int ID_OTHER
public JDialog getJDialog()
public Window getParent()
public String getTitle()
public void setTitle(String title)
title
- The dialog's title.public int getButtonMask()
public int getButtonID()
protected void setButtonID(int buttonID)
buttonID
- The identifier for the most recently pressed button.public String getHelpID()
public void setHelpID(String helpID)
helpID
- The help identifier.public JPanel getButtonPanel()
public Component getContent()
public void setContent(Component content)
content
- The dialog's content component.public void setContent(Object content)
content
- The dialog's content.public AbstractButton getButton(int buttonID)
buttonID
- The button identifier.null
.public int show()
super.show()
at the end.public void hide()
super.hide()
at the end. This method does nothing else than hiding the underlying Swing dialog.getJDialog()
public abstract void close()
public void center()
public void showErrorDialog(String errorMessage)
errorMessage
- The message.public static void showErrorDialog(Component component, String message, String dialogTitle)
public void showInformationDialog(String infoMessage)
infoMessage
- The message.public static void showInformationDialog(Component component, String message, String dialogTitle)
public void showWarningDialog(String warningMessage)
warningMessage
- The message.public static void showWarningDialog(Component component, String message, String dialogTitle)
protected void onOK()
hide()
.
Clients should override this method to implement meaningful behaviour.protected void onYes()
hide()
.
Clients should override this method to implement meaningful behaviour.protected void onNo()
hide()
.
Clients should override this method to implement meaningful behaviour.protected void onCancel()
hide()
.
Clients should override this method to implement meaningful behaviour.protected void onApply()
protected void onClose()
hide()
.
Clients should override this method to implement meaningful behaviour.protected void onReset()
protected void onHelp()
protected void onOther()
hide()
.
Clients should override this method to implement meaningful behaviour.protected boolean verifyUserInput()
true
if and only if the validation was successful.protected void collectButtons(List<AbstractButton> buttons)
buttons
- The container into which new buttons shall be collected.protected void registerButton(int buttonID, AbstractButton button)
Copyright © 2014–2017 European Space Agency (ESA). All rights reserved.