Package nl.colorize.util.swing
Class Popups
java.lang.Object
nl.colorize.util.swing.Popups
Utility class for working with pop-up windows. This class can be used instead
of calling
JOptionPane
directly. It makes sure that dialogs
look native on each platform, automatically word-wraps long messages, and
provides a number of convenience methods. Like JOptionPane
, pop-up
windows can specify a parent window or pass null
to be considered as
global for the entire application.
It's recommended to not rely on generic button labels such as "OK" or "cancel", since they can be confusing depending on the action performed by the pop-up window. Instead, try to use button labels that convey the action that is going to be performed, such as "save" or "download file".
-
Field Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic boolean
confirmMessage
(JFrame parent, String message) Shows a simple pop-up window that displays a text message and contains default "OK" and "cancel" buttons.static boolean
confirmMessage
(JFrame parent, String title, JComponent message) Shows a simple pop-up window that displays a text message and contains default "OK" and "cancel" buttons.static void
Shows a simple pop-up window that displays a text message and contains a default "OK" button.static void
Shows a simple pop-up window that displays a text message and contains a default "OK" button.static int
Shows a pop-up window that consists of the specified component and a number of buttons.static int
Shows a pop-up window that consists of the specified component and a number of buttons.static void
message
(JFrame parent, String title, JComponent message) Shows a simple pop-up window that displays a component and contains a default "OK" button.static int
message
(JFrame parent, String title, JComponent panel, String... buttons) Shows a pop-up window that consists of the specified component and a number of buttons.static int
Shows a pop-up window that consists of the specified component and a number of buttons.
-
Field Details
-
MESSAGE_WIDTH
public static final int MESSAGE_WIDTH- See Also:
-
-
Method Details
-
message
Shows a pop-up window that consists of the specified component and a number of buttons. The first button in the list is considered the "primary" button. This method will block until either one of the buttons is clicked or the dialog was cancelled.- Returns:
- The index of the button that was clicked. For example, if the first
button from
buttons
was clicked this will return 0. - Throws:
IllegalArgumentException
- if no buttons were supplied.
-
message
Shows a pop-up window that consists of the specified component and a number of buttons. The first button in the list is considered the "primary" button. This method will block until either one of the buttons is clicked or the dialog was cancelled.- Returns:
- The index of the button that was clicked. For example, if the first
button from
buttons
was clicked this will return 0. - Throws:
IllegalArgumentException
- if no buttons were supplied.
-
message
Shows a pop-up window that consists of the specified component and a number of buttons. The first button in the list is considered the "primary" button. This method will block until either one of the buttons is clicked or the dialog was cancelled.- Returns:
- The index of the button that was clicked. For example, if the first
button from
buttons
was clicked this will return 0. - Throws:
IllegalArgumentException
- if no buttons were supplied.
-
message
Shows a pop-up window that consists of the specified component and a number of buttons. The first button in the list is considered the "primary" button. This method will block until either one of the buttons is clicked or the dialog was cancelled.- Returns:
- The index of the button that was clicked. For example, if the first
button from
buttons
was clicked this will return 0. - Throws:
IllegalArgumentException
- if no buttons were supplied.
-
message
Shows a simple pop-up window that displays a component and contains a default "OK" button. -
message
Shows a simple pop-up window that displays a text message and contains a default "OK" button. -
message
Shows a simple pop-up window that displays a text message and contains a default "OK" button. -
confirmMessage
Shows a simple pop-up window that displays a text message and contains default "OK" and "cancel" buttons.- Returns:
- True when OK, false when cancelled.
-
confirmMessage
Shows a simple pop-up window that displays a text message and contains default "OK" and "cancel" buttons.- Returns:
- True when OK, false when cancelled.
-