Draw image icon loaded from disk - Java 2D Graphics

Java examples for 2D Graphics:BufferedImage Paint

Description

Draw image icon loaded from disk

Demo Code

import javax.swing.ImageIcon;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;

public class PictureApp extends JFrame {
  public static void main(String[] args) {
    new PictureApp();
  }//from  w w  w.ja v a  2 s .  c o  m

  public PictureApp() {
    this.setTitle("Picture Application");
    this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    JPanel panel1 = new JPanel();
    ImageIcon pic = new ImageIcon("test.jpg");
    panel1.add(new JLabel(pic));
    this.add(panel1);
    this.pack();
    this.setVisible(true);
  }
}

Related Tutorials