public class Dialogs extends Object
All of the methods in the Dialogs class are declared as static so the class
never needs to be instantiated. However, the class also provides a
getInstance method should an instance of the
class ever be required.
| Modifier and Type | Field and Description |
|---|---|
static int |
CANCEL
The same value as JOptionPane.CANCEL_OPTION
|
static int |
NO
The same value as JOptionPane.NO_OPTION
|
static int |
OK
The same value as JOptionPane.OK_OPTION
|
static int |
YES
The same value as JOptionPane.YES_OPTION
|
| Modifier and Type | Method and Description |
|---|---|
static boolean |
confirmBox(Component parent,
Object message)
Calls the three parameter version of this method with the title "Confirm".
|
static boolean |
confirmBox(Component parent,
Object message,
String title)
Displays a JOptionPane confirm dialog with the OK and CANCEL options.
|
static void |
errorBox(Component parent,
Exception ex) |
static void |
errorBox(Component parent,
Object message)
Calls the three parameter version of this method with the title "Error".
|
static void |
errorBox(Component parent,
Object message,
String title)
Displays a JOptionPane dialog of the type JOptionPane.ERROR_MESSAGE.
|
static Dialogs |
getInstance()
Returns an instance of the Dialogs class.
|
static String |
inputBox(Component parent,
Object message)
Calls the three parameter version of this method with the title "Question"
|
static String |
inputBox(Component parent,
Object message,
String title)
Displays a JOptionPane input dialog and returns the string entered.
|
static String |
inputBox(Component parent,
Object message,
String title,
String defaultValue)
Displays a JOptionPane input dialog and returns the string entered.
|
static JPanel |
makePanel(String[] lines)
Creates a panel containing a label for each string in
lines. |
static void |
messageBox(Component parent,
Object message)
Calls the three parameter version of the method with the title "Message"
|
static void |
messageBox(Component parent,
Object message,
String title)
Displays a JOptionPane dialog with the type
JOptionPane.INFORMATION_MESSAGE.
|
static int |
promptBox(Component parent,
Object message)
Calls the three parameter version of this method with the title "Confirm".
|
static int |
promptBox(Component parent,
Object message,
String title)
Displays a JOptionPane confirm dialog with the YES and NO options.
|
static void |
warningBox(Component parent,
Object message)
Calls the three parameter version of the method with the title "Warning".
|
static void |
warningBox(Component parent,
Object message,
String title)
Displays a JOptionPane dialog of the type JOptionPane.ERROR_MESSAGE.
|
static boolean |
yesNo(Component parent,
Object message)
Displays a JOptionPane confirm dialog with YES and NO buttons.
|
public static int OK
public static int CANCEL
public static int YES
public static int NO
public static Dialogs getInstance()
Since the Dialogs class is implemented as a singleton the same instance will always be returned.
public static void messageBox(Component parent, Object message)
public static void messageBox(Component parent, Object message, String title)
parent - The parent component of the dialog.message - The message to display in the dialog.title - The title to display the dialog.public static void errorBox(Component parent, Object message)
public static void errorBox(Component parent, Object message, String title)
parent - The parent component of the dialog.message - The message to display in the dialog.title - The title to display in the dialog.public static void warningBox(Component parent, Object message)
public static void warningBox(Component parent, Object message, String title)
parent - The parent component of the dialog.message - The message to display in the dialog.title - The title to display in the dialog.public static boolean confirmBox(Component parent, Object message)
public static boolean confirmBox(Component parent, Object message, String title)
parent - The parent component of the dialog.message - The message to display in the dialog.title - The title to display in the dialog.public static boolean yesNo(Component parent, Object message)
public static int promptBox(Component parent, Object message)
public static int promptBox(Component parent, Object message, String title)
public static String inputBox(Component parent, Object message)
public static String inputBox(Component parent, Object message, String title)
parent - The parent component of the dialog.message - The message to display in the dialog.title - The title to display in the dialog.public static String inputBox(Component parent, Object message, String title, String defaultValue)
parent - The parent component of the dialog.message - The message to display in the dialog.title - The title to display in the dialog.defaultValue - The initial value displayed in the dialog.public static JPanel makePanel(String[] lines)
lines.
The labels are arranged in a single column and the text is centered in each label.
lines - The text to use for each label.lines.Copyright © 2016 The American National Corpus. All rights reserved.