Message dialog with own image

For working with dialogs in Java you need use this include:

import javax.swing.JOptionPane;
When you need own image in your message box, you can use class ImageIcon.
ImageIcon icon = new ImageIcon( "c:\\add_white_page.png" );

JOptionPane.showMessageDialog( null, "This is message.", "Title", JOptionPane.ERROR_MESSAGE, icon );
This example read image from file on the disc.
What is important: Java could read .png, .gif and .jpg format. When you try read for example .bmp format, internal ImageIcon image stay empty (JDK 1.6).