Fields of JOptionPane

Fields

Description

int ERROR_MESSAGE

A Constant code displaying an error message icon.

int INFORMATION_MESSAGE

A Constant code displaying information message icon.

int WARNING_MESSAGE

A Constant code for displaying Warning message icon.

int YES_NO_OPTION

A constant for creating a dialog with “Yes” and “No” options.

int YES_NO_CANCEL_OPTION

A constant for creating a dialog with “Yes,” “No,” and “Cancel” options.

int OK_CANCEL_OPTION

A constant for creating a dialog with “OK” and “Cancel” options.

Java JOptionPane

In Java, JOptionPane is a part of the Java Swing library. It helps us to create dialog boxes such as message dialogs, conformation dialogs, input dialogs, and options dialogs In this article, we are going to explore some constructors, methods, and some examples of JOptionPane.

Similar Reads

Constructors of JOptionPane Class

...

Methods of JOptionPane

Methods Description createDialog(String title) It helps us to create JDialog with a specified title but without any parent. showMessageDialog(Component parentComponent, Object message) This method displays a message dialog with the specified message. showInputDialog(Component parentComponent, Object message) This method displays an input dialog with the specified message. setMessageType(int messageType) This method to set the message type of the dialog setOptionType(int optionType) This method allows you to set the option type for the dialog. setOptions(Object[] options) Here we can set a list of custom options. setInitialValue(Object initialValue) This method sets the initial selection when using custom options in the dialog....

Fields of JOptionPane

Fields Description int ERROR_MESSAGE A Constant code displaying an error message icon. int INFORMATION_MESSAGE A Constant code displaying information message icon. int WARNING_MESSAGE A Constant code for displaying Warning message icon. int YES_NO_OPTION A constant for creating a dialog with “Yes” and “No” options. int YES_NO_CANCEL_OPTION A constant for creating a dialog with “Yes,” “No,” and “Cancel” options. int OK_CANCEL_OPTION A constant for creating a dialog with “OK” and “Cancel” options....

Classes from Which JOptionPane Methods are inherited

java.awt.Component javax.swing.JComponent java.io.Serializable...

Following are the programs to implement JOptionPane

1. Java program to create a showMessageDialog in JOptionPane...