forked from ChrisMayfield/ThinkJavaCode2
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSim1.java
More file actions
41 lines (34 loc) · 1.08 KB
/
Sim1.java
File metadata and controls
41 lines (34 loc) · 1.08 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
import java.awt.Color;
import javax.swing.JFrame;
/**
* Example simulation of stationary objects.
*/
public class Sim1 {
/**
* Test program that draws a few polygons.
*
* @param args command-line arguments
*/
public static void main(String[] args) {
// create some regular polygons
RegularPolygon p3 = new RegularPolygon(3, 100, Color.GREEN);
RegularPolygon p4 = new RegularPolygon(4, 100, Color.ORANGE);
RegularPolygon p5 = new RegularPolygon(360, 1, Color.MAGENTA);
// move them out of the corner
p3.translate(100, 100);
p4.translate(250, 250);
p5.translate(400, 400);
// create drawing, add polygons
Drawing drawing = new Drawing(800, 600);
drawing.add(p3);
drawing.add(p4);
drawing.add(p5);
// set up the window frame
JFrame frame = new JFrame("Drawing");
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setResizable(false);
frame.add(drawing);
frame.pack();
frame.setVisible(true);
}
}