public class SwingDialog extends Object
It is very similar to the dialog generated by
JOptionPane.showConfirmDialog(Component, Object, String, int, int)
,
except that it has a few extra features:
Component
in case it is too large.Component
having the keyboard
focus.Modifier and Type | Field and Description |
---|---|
static int |
UNKNOWN_OPTION
Catch-all return value of
show() if return value is non-integer. |
Constructor and Description |
---|
SwingDialog(Component c,
int messageType,
boolean scrollBars)
Creates a dialog box containing the given component.
|
SwingDialog(Component c,
int optionType,
int messageType,
boolean scrollBars)
Creates a dialog box containing the given component.
|
Modifier and Type | Method and Description |
---|---|
Component |
getFocus()
Gets the
Component that will have the initial keyboard focus. |
Component |
getParent()
Gets the frame in which the dialog is displayed.
|
String |
getTitle()
Gets the title string that will be displayed in the dialog title bar.
|
boolean |
isModal()
Gets whether the dialog is modal.
|
boolean |
isResizable()
Gets whether the dialog is resizable by the user.
|
boolean |
isSizeLimited()
Gets whether the dialog's size is limited by the screen size.
|
boolean |
isVisible()
Whether the dialog is currently being shown onscreen.
|
void |
setFocus(Component focusComponent)
Sets the
Component that will have the initial keyboard focus. |
void |
setModal(boolean modal)
Specifies whether this dialog should be modal.
|
void |
setParent(Component parentComponent)
Sets the frame in which the dialog is displayed; if the
parentComponent has no Frame , a default one
is used. |
void |
setResizable(boolean resizable)
Sets whether this dialog is resizable by the user.
|
void |
setSizeLimited(boolean sizeLimited)
Sets whether this dialog's size is limited by the screen size.
|
void |
setTitle(String title)
Sets the title string to display in the dialog title bar.
|
int |
show()
Shows the dialog.
|
public static final int UNKNOWN_OPTION
show()
if return value is non-integer.public SwingDialog(Component c, int messageType, boolean scrollBars)
By default, the dialog is modal, resizable, and size limited, with no parent component and no explicit focus component.
If shown as a modal dialog, there will be a single OK button; otherwise, no buttons will be displayed.
c
- the Component
to displaymessageType
- the type of message to be displayed:
JOptionPane.ERROR_MESSAGE
,
JOptionPane.INFORMATION_MESSAGE
,
JOptionPane.WARNING_MESSAGE
,
JOptionPane.QUESTION_MESSAGE
, or
JOptionPane.PLAIN_MESSAGE
scrollBars
- whether to show scroll bars if the content is too large
to fit in the window.public SwingDialog(Component c, int optionType, int messageType, boolean scrollBars)
By default, the dialog is modal, resizable, and size limited, with no parent component and no explicit focus component.
If shown as a modal dialog, there will be buttons corresponding to the
specified optionType
; otherwise, no buttons will be displayed.
c
- the Component
to displayoptionType
- the options to display in the pane:
JOptionPane.DEFAULT_OPTION
,
JOptionPane.YES_NO_OPTION
,
JOptionPane.YES_NO_CANCEL_OPTION
, or
JOptionPane.OK_CANCEL_OPTION
messageType
- the type of message to be displayed:
JOptionPane.ERROR_MESSAGE
,
JOptionPane.INFORMATION_MESSAGE
,
JOptionPane.WARNING_MESSAGE
,
JOptionPane.QUESTION_MESSAGE
, or
JOptionPane.PLAIN_MESSAGE
scrollBars
- whether to show scroll bars if the content is too large
to fit in the window.public Component getParent()
public void setParent(Component parentComponent)
parentComponent
has no Frame
, a default one
is used.public void setFocus(Component focusComponent)
Component
that will have the initial keyboard focus.public String getTitle()
public void setTitle(String title)
public boolean isModal()
public void setModal(boolean modal)
Note that non-modal dialogs do not show any buttons (e.g., OK or Cancel),
regardless of the specified optionType
, since the show()
method does not block in that case.
modal
- specifies whether dialog blocks input to other windows when
shownpublic boolean isResizable()
public void setResizable(boolean resizable)
resizable
- true
if the user can resize this dialog;
false
otherwise.Dialog.isResizable()
public boolean isSizeLimited()
public void setSizeLimited(boolean sizeLimited)
public int show()
optionType
, will be one of:
JOptionPane.YES_OPTION
JOptionPane.NO_OPTION
JOptionPane.CANCEL_OPTION
JOptionPane.OK_OPTION
JOptionPane.CLOSED_OPTION
UNKNOWN_OPTION
JOptionPane.OK_OPTION
is always
returned, regardless of the specified optionType
.public boolean isVisible()
Copyright © 2015–2022 SciJava. All rights reserved.