JOptionPane showMessageDialog with Icon

showMessageDialog( Component parent, Object message, String title, int messageType, Icon icon)

The first argument is the parent for the dialog that is used to position the dialog.The second argument specifies what is to be displayed in addition to the default OK button. Third argument specifies by the title. The fourth argument specifies messageType. if you except that the icon is what you pass as the fifth argument.

Program

 

 

 

Program Source

import javax.swing.JOptionPane;
import javax.swing.ImageIcon;

public class Javaapp {

      public static void main(String[] args) {
          
          ImageIcon icon = new ImageIcon("WLive48x48.png");
          JOptionPane.showMessageDialog(null,"Message","Title",JOptionPane.PLAIN_MESSAGE,icon);
    }
}

Leave a Comment