Source Code : Display image supported by ImageIO

Java Is Open Source Programming Language You Can Download From Java and Java Libraries From http://www.oracle.com. Click Here to download
We provide this code related to title for you to solve your developing problem easily. Libraries which is import in this program you can download from http://www.oracle.com. Click Here or search from google with Libraries Name you get jar file related it

Display image supported by ImageIO

      

import java.awt.Graphics;
import java.awt.Panel;
import java.awt.image.BufferedImage;
import java.io.File;
import java.io.IOException;

import javax.imageio.ImageIO;
import javax.swing.JFrame;

public class ShowImage extends Panel {
  private static final long serialVersionUID = 1L;

  private BufferedImage image;

  public ShowImage(String filename) {
    try {
      image = ImageIO.read(new File(filename));
    } catch (IOException ie) {
      ie.printStackTrace();
    }
  }

  public void paint(Graphics g) {
    g.drawImage(image, 0, 0, null);
  }

  static public void main(String args[]) throws Exception {
    JFrame frame = new JFrame("ShowImage.java");
    Panel panel = new ShowImage(args[0]);
    frame.getContentPane().add(panel);
    frame.setSize(400, 400);
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    frame.setVisible(true);
  }
}

           
         
    
    
    
    
    
  

Thank with us