Here you can find the source of showImage(BufferedImage img)
Parameter | Description |
---|---|
img | a parameter |
public static void showImage(BufferedImage img)
//package com.java2s; //License from project: Open Source License import javax.swing.*; import java.awt.*; import java.awt.image.BufferedImage; public class Main { /**/*from ww w . j av a2 s . c om*/ * Show image in window * * @param img */ public static void showImage(BufferedImage img) { showImage("", img); } /** * Show image in windwos, with specified title * * @param title * @param img */ public static void showImage(String title, BufferedImage img) { SwingUtilities.invokeLater(() -> { JFrame frame = new JFrame(); frame.setTitle(title + " " + img.toString()); // create label for image, with border JLabel lbl = new JLabel(new ImageIcon(img)); lbl.setBorder(BorderFactory.createLineBorder(Color.blue)); JPanel content = new JPanel(); content.add(lbl); frame.setContentPane(content); frame.pack(); frame.setLocationRelativeTo(null); frame.setVisible(true); }); } }