Here you can find the source of showImage(final String title, final Image image)
public static void showImage(final String title, final Image image)
//package com.java2s; //License from project: Open Source License import java.awt.EventQueue; import java.awt.Image; import javax.swing.ImageIcon; import javax.swing.JFrame; import javax.swing.JLabel; public class Main { public static void showImage(final String title, final Image image) { EventQueue.invokeLater(new Runnable() { @Override//from w ww.j av a2s .com public void run() { try { JFrame jFrame = new JFrame(title); jFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); jFrame.add(new JLabel(new ImageIcon(image))); jFrame.pack(); jFrame.setVisible(true); } catch (Exception e) { e.printStackTrace(); } } }); try { Thread.sleep(2000); } catch (InterruptedException e) { // TODO Auto-generated catch block e.printStackTrace(); } } }