display BufferedImage - Java 2D Graphics

Java examples for 2D Graphics:BufferedImage

Description

display BufferedImage

Demo Code


//package com.java2s;

import javax.swing.*;

import java.awt.image.BufferedImage;

public class Main {
    public static void displayImage(final BufferedImage image) {
        displayImage("", image);
    }/*w  w  w.j  a v a 2  s .c  om*/

    public static void displayImage(final String windowTitle,
            final BufferedImage image) {
        new JFrame(windowTitle) {
            {
                final JLabel label = new JLabel("", new ImageIcon(image), 0);
                add(label);
                pack();
                setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
                setVisible(true);
            }
        };
    }
}

Related Tutorials