Java Image showImage(Image image)

Here you can find the source of showImage(Image image)

Description

show Image

License

Open Source License

Declaration

public static void showImage(Image image) 

Method Source Code

//package com.java2s;
/*******************************************************************************
 * Copyright (c) 2014 Open Door Logistics (www.opendoorlogistics.com)
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the GNU Lesser Public License v3
 * which accompanies this distribution, and is available at http://www.gnu.org/licenses/lgpl.txt
 ******************************************************************************/

import java.awt.Color;

import java.awt.Image;

import javax.swing.ImageIcon;
import javax.swing.JFrame;

import javax.swing.JLabel;
import javax.swing.JPanel;

public class Main {
    public static void showImage(Image image) {
        createImageFrame(image).setVisible(true);
    }//from  w  ww  .j  av a 2s. c  om

    public static JFrame createImageFrame(Image image) {
        JFrame ret = new JFrame();
        ret.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
        ret.add(createImagePanel(image, null));
        ret.pack();
        return ret;
    }

    public static JPanel createImagePanel(Image image, Color backColor) {
        JPanel panel = new JPanel();
        panel.add(new JLabel(new ImageIcon(image)));
        if (backColor != null) {
            panel.setBackground(backColor);
        }
        return panel;
    }
}

Related

  1. SaveImageToFile(Image img, String filename, String outformat)
  2. scaleBarcodeMaxWidth(Image i, int width, int cropHeigth)
  3. setImage(Image im, JComponent c)
  4. setImageDimension(Image imagen)
  5. showImage(final String title, final Image image)
  6. showImage(Image image, String title)
  7. sizeToImage(JComponent component, Image image)
  8. swapColor(Image image, Color imageColor, Color newColor)
  9. texturePaintHorizontal(JComponent parent, Graphics g, Image image, Rectangle areaToPaint)