Java examples for 2D Graphics:Image
display Image
/**//from w w w. j a v a2s . c o m * Heatmap Framework - Core * * Copyright (C) 2013 Martin Becker * becker@informatik.uni-wuerzburg.de * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as * published by the Free Software Foundation, either version 3 of the * License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public * License along with this program. If not, see * <http://www.gnu.org/licenses/gpl-3.0.html>. */ //package com.java2s; import java.awt.FlowLayout; import java.awt.image.BufferedImage; import java.io.IOException; import javax.swing.ImageIcon; import javax.swing.JFrame; import javax.swing.JLabel; public class Main { public static void displayImage(BufferedImage image) throws IOException { ImageIcon icon = new ImageIcon(image); JFrame frame = new JFrame(); frame.setLayout(new FlowLayout()); frame.setSize(200, 300); JLabel lbl = new JLabel(); lbl.setIcon(icon); frame.add(lbl); frame.setVisible(true); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); } }