Package br.com.neto.main

Source Code of br.com.neto.main.ReadAndShowImage

package br.com.neto.main;

import java.awt.BorderLayout;
import java.awt.Image;
import java.io.BufferedInputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStream;

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

import br.com.neto.util.Constantes;

public class ReadAndShowImage {

 
  @SuppressWarnings("static-access")
  public static void main(String[] args) {

    Constantes c = Constantes.getInstance();
    File imagem = new File(c.FILE_DIRETORIO + c.SLASH + "elfa.png");
    Image image = null;
   
    try(InputStream is = new BufferedInputStream(new FileInputStream(imagem))){
     
      image = ImageIO.read(is);
     
      JFrame frame = new JFrame();
      JLabel label = new JLabel(new ImageIcon(image));
      frame.getContentPane().add(label, BorderLayout.CENTER);
      frame.pack();
      frame.setVisible(true);

    }catch (IOException e) {
      System.out.println(e.getMessage());
    }
  }
}
TOP

Related Classes of br.com.neto.main.ReadAndShowImage

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.