-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathImageDemo.java
More file actions
36 lines (29 loc) · 840 Bytes
/
Copy pathImageDemo.java
File metadata and controls
36 lines (29 loc) · 840 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
import java.awt.*;
import javax.swing.JFrame;
import java.io.File;
import javax.imageio.ImageIO;
public class ImageDemo extends Canvas
{
Image coolFace;
public ImageDemo() throws Exception
{
coolFace = ImageIO.read( new File("mitch.png") );
// Java supports PNG, JPEG, and GIF (but not animated GIFs). It does not support BMP.
}
public void paint( Graphics g )
{
// Image , x, y, this
g.drawImage(coolFace,100,100,this);
// And, just for fun, let's give me a halo! This halo designed by Liz O in 2012.
g.setColor( Color.yellow );
g.drawOval(88,88,70,25);
}
public static void main(String[] args) throws Exception
{
JFrame win = new JFrame("Image Demo");
win.setSize(1024,768);
win.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
win.add( new ImageDemo() );
win.setVisible(true);
}
}