JOptionPane Class
Package: javax.swing
JOptionPane
has a number of static methods that display generic dialog boxes for simple user interaction. It is commonly used to display error or informational messages, to get the user’s confirmation to proceed with an operation, or to get a single input value.
Fields
Button Option Field |
Description |
|
Yes or No. |
|
Yes, No, or Cancel. |
|
OK or Cancel. |
Message Type Field |
Description |
|
Error message. |
|
Informational message. |
|
Warning message. |
|
Question message. |
|
A plain message with no icon. |
Return Value Field |
Description |
|
The user clicked Yes. |
|
The user clicked No. |
|
The user clicked OK. |
|
The user clicked Cancel. |
|
The user closed the dialog box. |
Methods
Method |
Description |
|
Displays the indicated message and offers the user three choices: Yes, No, and Cancel. The user’s choice is indicated by the return value. The dialog box’s title defaults to |
|
Get Java For Dummies Quick Reference now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.