Java BufferedImage Show showImage(BufferedImage img)

Here you can find the source of showImage(BufferedImage img)

Description

Creates a modal pop-up window showing an image.

License

GNU General Public License

Parameter

Parameter Description
img An image to show on the screen in a pop-up window.

Declaration

public static void showImage(BufferedImage img) 

Method Source Code


//package com.java2s;
/*/*from  www.j  a v  a 2s  .  com*/
CCH World Factory - GPL
    
Copyright (C) 2014 Christopher Collin Hall
email: explosivegnome@yahoo.com
    
CCH World Factory - GPL is distributed under the GNU General Public 
License (GPL) version 3. A non-GPL branch of the CCH World Factory 
also exists. For non-GPL licensing options, contact the copyright 
holder, Christopher Collin Hall (explosivegnome@yahoo.com). 
    
CCH World Factory - GPL 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.
    
CCH World Factory - GPL 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 CCH World Factory - GPL.  If not, see 
<http://www.gnu.org/licenses/>.
    
*/

import java.awt.FlowLayout;
import java.awt.image.BufferedImage;

import javax.swing.ImageIcon;
import javax.swing.JDialog;

import javax.swing.JLabel;

import javax.swing.JScrollPane;

public class Main {
    /**
     * Creates a modal pop-up window showing an image.
     * @param img An image to show on the screen in a pop-up window.
     */
    public static void showImage(BufferedImage img) {
        JLabel ic = new JLabel(new ImageIcon(img));
        JScrollPane scroller = new JScrollPane(ic);
        JDialog popup = new JDialog();
        popup.getContentPane().setLayout(new FlowLayout());
        popup.getContentPane().add(scroller);
        popup.getContentPane().validate();
        popup.setModal(true);
        popup.pack();
        popup.setVisible(true);
    }
}

Related

  1. show(final BufferedImage image, final int width, final int height)
  2. showBufferedImage(BufferedImage I)
  3. showImage(BufferedImage im)
  4. showImage(BufferedImage image, String title, boolean fitToScreen)
  5. showImage(BufferedImage img)
  6. showImage(final BufferedImage img, final HashMap inputHandles, final HashMap outputHandles)
  7. showImage(String title, BufferedImage image)
  8. showImageLabel(BufferedImage imagen, JLabel jLabel, JComponent jc)