-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathImageDemoShowingImagesOnScreen.java
More file actions
47 lines (39 loc) · 1.17 KB
/
Copy pathImageDemoShowingImagesOnScreen.java
File metadata and controls
47 lines (39 loc) · 1.17 KB
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
37
38
39
40
41
42
43
44
45
46
47
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package assignment_10528808;
/**
*
* @author Mawutor
*/
import java.awt.*;
import javax.swing.JFrame;
import java.io.File;
import javax.imageio.ImageIO;
public class ImageDemoShowingImagesOnScreen extends Canvas
{
Image coolFace;
public ImageDemoShowingImagesOnScreen() 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 ImageDemoShowingImagesOnScreen() );
win.setVisible(true);
}
}