-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathGraphicsDemo2.java
More file actions
62 lines (50 loc) · 1.66 KB
/
Copy pathGraphicsDemo2.java
File metadata and controls
62 lines (50 loc) · 1.66 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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
/*
* 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;
public class GraphicsDemo2 extends Canvas
{
public void paint( Graphics g )
{
g.setColor(Color.black);
g.drawRect(50,20,100,200); // draw a rectangle
g.drawOval(160,20,100,200); // draw a filled-in oval
//arcs
g.drawArc(270,20,100,200,0,270); // draw an arc that starts at 0 degrees
// and has an arclength of 270 degrees
g.drawArc(50,250,150,150,90,180); // from 90 degrees to 270 (90+180)
g.drawArc(210,250,150,150,45,90); // from 45 degrees to 135 (45+90)
g.fillArc(210,280,150,150,45,90); // ditto, but filled in
g.setColor(Color.yellow);
g.fillArc(150,400,150,150,45,270); // chomp
// custom colors
Color myOrange = new Color(230,92,0); // the amount of red, green, blue in the color
// Each component has a value from 0-255.
g.setColor(myOrange);
g.fillOval(500,50,150,150);
Color myGrey = new Color(238,238,238);
g.setColor(myGrey);
g.fillOval(550,100,50,50);
g.setColor(Color.yellow);
g.fillOval(500,210,150,150);
g.setColor(Color.green);
g.fillOval(500,370,150,150);
}
public static void main( String[] args )
{
JFrame win = new JFrame("GraphicsDemo2: Arcs and Colors");
win.setSize(800,600);
win.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
GraphicsDemo2 canvas = new GraphicsDemo2();
win.add( canvas );
win.setVisible(true);
}
}