1BufferedImage myPicture = ImageIO.read(new File("path-to-file"));
2JLabel picLabel = new JLabel(new ImageIcon(myPicture));
3add(picLabel);
1import java.awt.*;
2import javax.swing.JFrame;
3
4public class MyCanvas extends Canvas{
5
6 public void paint(Graphics g) {
7
8 Toolkit t=Toolkit.getDefaultToolkit();
9 Image i=t.getImage("p3.gif");
10 g.drawImage(i, 120,100,this);
11
12 }
13 public static void main(String[] args) {
14 MyCanvas m=new MyCanvas();
15 JFrame f=new JFrame();
16 f.add(m);
17 f.setSize(400,400);
18 f.setVisible(true);
19 }
20
21}