Package rsb.util
Class WindowUtil
java.lang.Object
rsb.util.WindowUtil
Main application window and dialog utilities.
- Author:
- Enfilade
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final int
Returned from showConfirmDialog when the user hits the "Cancel" button.static final int
Returned from showConfirmDialog when the user closes the dialog.static final int
Returned from showConfirmDialog when the user hits the "No" button.static final int
Use this for a confirm dialog with options "Ok" and "Cancel" (in that order)static final int
Returned from showConfirmDialog when the user hits the "OK" button.static final int
Use this for a confirm dialog with options "Yes" and "No" (in that order)static final int
Use this for a confirm dialog with options "Yes", "No", and "Cancel" (in that order)static final int
Returned from showConfirmDialog when the user hits the "Yes" button. -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic Point
Gets the window's point on screen.static void
Maximizes the window.static void
Minimizes the window.static void
Centers a JFrame so that its position is in the center of the window.static void
Restores the window (if it is minimized).static void
Sets the frame that WindowUtil will use.static int
showConfirmDialog
(String message) Shows a confirm dialog with "Yes", "No", and "Cancel" buttons.static int
showConfirmDialog
(String message, int type) Shows a confirm dialog with the specified buttons.static void
showDialog
(String message) Shows a dialog window that appears centered in front of the Bot window that can be used to alert the user.static String
showInputDialog
(String message) Shows an input dialog with the given message.static void
"Unmaximizes" the window.
-
Field Details
-
YES_OPTION
public static final int YES_OPTIONReturned from showConfirmDialog when the user hits the "Yes" button.- See Also:
-
NO_OPTION
public static final int NO_OPTIONReturned from showConfirmDialog when the user hits the "No" button.- See Also:
-
CANCEL_OPTION
public static final int CANCEL_OPTIONReturned from showConfirmDialog when the user hits the "Cancel" button.- See Also:
-
OK_OPTION
public static final int OK_OPTIONReturned from showConfirmDialog when the user hits the "OK" button.- See Also:
-
DIALOG_CLOSED
public static final int DIALOG_CLOSEDReturned from showConfirmDialog when the user closes the dialog.- See Also:
-
YES_NO_CANCEL
public static final int YES_NO_CANCELUse this for a confirm dialog with options "Yes", "No", and "Cancel" (in that order)- See Also:
-
YES_NO
public static final int YES_NOUse this for a confirm dialog with options "Yes" and "No" (in that order)- See Also:
-
OK_CANCEL
public static final int OK_CANCELUse this for a confirm dialog with options "Ok" and "Cancel" (in that order)- See Also:
-
-
Constructor Details
-
WindowUtil
public WindowUtil()
-
-
Method Details
-
setFrame
Sets the frame that WindowUtil will use. This method only sets it on the first call, to prevent tampering.- Parameters:
f
- The JFrame that WindowUtil should use.
-
showDialog
Shows a dialog window that appears centered in front of the Bot window that can be used to alert the user. This dialog will keep focus until the user closes it.- Parameters:
message
- The message to be shown within the dialog.
-
showInputDialog
Shows an input dialog with the given message. Text entered into the dialog box will be returned. This dialog will keep focus until the user hits OK or the user closes it.- Parameters:
message
- The message to be shown in the dialog.- Returns:
- A string containing input the user entered into the box, or null if the user hit "Cancel" or closed the dialog.
-
showConfirmDialog
Shows a confirm dialog with "Yes", "No", and "Cancel" buttons.- Parameters:
message
- The message to appear in the dialog.- Returns:
- an int representing the selected value. This value will be: JOptionPane. This can be any of the following: YES_OPTION - if the "Yes" option was pressed. NO_OPTION - if the "No" option was pressed. CANCEL_OPTION - if the "Cancel" option was pressed. DIALOG_CLOSED - if the user closed the dialog.
-
showConfirmDialog
Shows a confirm dialog with the specified buttons. This dialog will keep focus until the user closes it.- Parameters:
message
- The message to be displayed in the dialog.type
- The type of window. This can be any of the following: YES_NO_CANCEL - for a dialog that has "Yes", "No", and "Cancel" options. YES_NO - for a dialog that has "Yes" and "No" options. OK_CANCEL - for a dialog that has "Ok" and "Cancel" options.- Returns:
- an int specifying what option was pressed. This can be any of the following: YES_OPTION - if the "Yes" option was pressed. NO_OPTION - if the "No" option was pressed. OK_OPTION - if the "Ok" option was pressed. CANCEL_OPTION - if the "Cancel" option was pressed. DIALOG_CLOSED - if the dialog was closed without an option being pressed.
-
position
Centers a JFrame so that its position is in the center of the window.- Parameters:
f
- The JFrame to be positioned.
-
getWindowLocation
Gets the window's point on screen.- Returns:
- a Point representing its point on screen.
-
minimizeWindow
public static void minimizeWindow()Minimizes the window. -
restoreWindow
public static void restoreWindow()Restores the window (if it is minimized). -
unmaximizeWindow
public static void unmaximizeWindow()"Unmaximizes" the window. This is the same thing as clicking the "Restore Down" button on Windows when the window is maximized. -
maximizeWindow
public static void maximizeWindow()Maximizes the window.
-