Program to demonstrate working of JOptionPane's Message Dialog in Java Swing
Output of the program :
Watch the Youtube video below for better understanding ...
import javax.swing.ImageIcon;
import javax.swing.JOptionPane;
public class MessageDialogDemo {
public static void main(String[] args) {
JOptionPane.showMessageDialog(null, "Hello World !!!");
JOptionPane.showMessageDialog(null, "Hello World !!!", "Welcome",
JOptionPane.PLAIN_MESSAGE);
JOptionPane.showMessageDialog(null, "Hello World !!!", "Welcome",
JOptionPane.INFORMATION_MESSAGE);
JOptionPane.showMessageDialog(null, "Hello World !!!", "Welcome",
JOptionPane.WARNING_MESSAGE);
JOptionPane.showMessageDialog(null, "Hello World !!!", "Welcome",
JOptionPane.QUESTION_MESSAGE);
JOptionPane.showMessageDialog(null, "Hello World !!!", "Welcome",
JOptionPane.ERROR_MESSAGE);
ImageIcon icon = new ImageIcon("CD.png");
JOptionPane.showMessageDialog(null, "Hello World !!!", "Welcome",
JOptionPane.INFORMATION_MESSAGE, icon);
}
}
Output of the program :
Watch the Youtube video below for better understanding ...






