You can add your own ImageIcon to JOptionPane - check the API and try calling methods with the Icon field, passing in your own ImageIcon to find out how it works. You can also create a complex JPanel, a full-fledged GUI-containing JPanel, and make it the basis for your JOptionPane by simply passing it as the Object parameter (usually the second parameter) of the JOptionPane.showXXX(...) method.
Another option is to create and use your own modal JDialog.
Work code:
import java.awt.Color; import javax.swing.*; public class JOptionPaneExample { private void createAndDisplayGUI() { JOptionPane.showMessageDialog(null, getOptionPanel(), "Modified JOptionPane : ", JOptionPane.PLAIN_MESSAGE); } public static void main(String... args) { SwingUtilities.invokeLater(new Runnable() { public void run() { new JOptionPaneExample().createAndDisplayGUI(); } }); } private JPanel getOptionPanel() { JPanel panel = new JPanel(); panel.setOpaque(true); panel.setBackground(Color.RED); try { java.net.URL url = new java.net.URL("http://gagandeepbali.uk.to/gaganisonline/images/swing/geek.gif"); ImageIcon image = new ImageIcon(url); JLabel label = new JLabel("I am one MODIFIED JOPTIONPANE LABEL.", image, JLabel.RIGHT); panel.add(label); } catch(Exception e) { e.printStackTrace(); } return panel; } }
Hovercraft full of eels
source share