Here you can find the source of show(final BufferedImage image, final int width, final int height)
public static void show(final BufferedImage image, final int width, final int height)
//package com.java2s; //License from project: Apache License import java.awt.BorderLayout; import java.awt.Graphics; import java.awt.image.BufferedImage; import javax.swing.JFrame; import javax.swing.JPanel; import javax.swing.WindowConstants; public class Main { public static void show(final BufferedImage image, String title) { show(image, image.getWidth() + 100, image.getHeight() + 100, title); }/* w w w. j a va2s. com*/ public static void show(final BufferedImage image) { show(image, image.getWidth() + 100, image.getHeight() + 100); } public static void show(final BufferedImage image, final int width, final int height) { show(image, width, height, ""); } public static void show(final BufferedImage image, final int width, final int height, final String title) { java.awt.EventQueue.invokeLater(new Runnable() { @Override @SuppressWarnings("serial") public void run() { new JFrame() { { setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE); setTitle(title); setSize(width, height); setVisible(true); getContentPane().setLayout(new BorderLayout()); final JPanel panel = new JPanel() { @Override public void paintComponent(Graphics g) { super.paintComponent(g); g.drawImage(image, 50, 50, null); } }; getContentPane().add(panel, BorderLayout.CENTER); } }; } }); } }