JOptionPane showMessageDialog

Introduction :

The JOptionPane class in the javax.swing package. A class used to create any number of different types of dialog boxes, including attention dialogs, yes/no dialogs, and input dialogs.

showMessageDialog () :

showMessageDialog( Component parent, Object message)

This displays a modal dialog with the default title “Message”. The first argument is the parent for the dialog that is used to position the dialog. If the first argument is null, a default Frame object is created and used to position the dialog centrally on the screen. The second argument specifies what is to be displayed in addition to the default OK button. This can be a String object specifying the message.

You usually get a default icon for an information message along with your message.

Program

 

 

 

Program Source

import javax.swing.JOptionPane;

public class Javaapplication{

   public static void main(String[] args) {

      JOptionPane.showMessageDialog(null,"Message");
   }
}

Leave a Comment