-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathRectangles.java
More file actions
38 lines (29 loc) · 786 Bytes
/
Rectangles.java
File metadata and controls
38 lines (29 loc) · 786 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
37
38
//(c) A+ Computer Science
// www.apluscompsci.com
//graphics example for rectangles
import java.awt.Graphics;
import java.awt.Color;
import java.awt.Canvas;
public class Rectangles extends Canvas
{
public Rectangles()
{
setBackground(Color.WHITE);
}
public void paint( Graphics window )
{
window.setColor(Color.BLACK);
window.drawString("Squares - Rectangles", 100, 50);
window.setColor(Color.BLUE);
//fillRect(int x1, int y1, int width, int height)
window.fillRect(100, 100, 100, 20 );
window.setColor(Color.GRAY);
window.drawRect(100,150,50,40);
window.setColor(Color.RED);
window.fillRect(100,200,40,40);
window.setColor(Color.BLUE);
window.drawRect(100,250,20,40);
window.setColor(Color.ORANGE);
window.fillRect(100,300,90,20);
}
}