Java Image showImage(final String title, final Image image)

Here you can find the source of showImage(final String title, final Image image)

Description

show Image

License

Open Source License

Declaration

public static void showImage(final String title, final Image image) 

Method Source Code


//package com.java2s;
//License from project: Open Source License 

import java.awt.EventQueue;
import java.awt.Image;
import javax.swing.ImageIcon;
import javax.swing.JFrame;
import javax.swing.JLabel;

public class Main {
    public static void showImage(final String title, final Image image) {
        EventQueue.invokeLater(new Runnable() {
            @Override//from w ww.j av a2s  .com
            public void run() {
                try {
                    JFrame jFrame = new JFrame(title);
                    jFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
                    jFrame.add(new JLabel(new ImageIcon(image)));
                    jFrame.pack();
                    jFrame.setVisible(true);
                } catch (Exception e) {
                    e.printStackTrace();
                }
            }
        });
        try {
            Thread.sleep(2000);
        } catch (InterruptedException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }
    }
}

Related

  1. saveComponentAsImage(final String path, final Component target, final String format)
  2. SaveImageToFile(Image img, String filename, String outformat)
  3. scaleBarcodeMaxWidth(Image i, int width, int cropHeigth)
  4. setImage(Image im, JComponent c)
  5. setImageDimension(Image imagen)
  6. showImage(Image image)
  7. showImage(Image image, String title)
  8. sizeToImage(JComponent component, Image image)
  9. swapColor(Image image, Color imageColor, Color newColor)