Java Reference
In-Depth Information
41 =
new
Point2D.Double(xLeft +
20
,
yTop);
42 //
The rear of the roof
43 Point2D.Double r3
44 =
new
Point2D.Double(xLeft +
40
,
yTop);
45 //
The bottom of the rear windshield
46 Point2D.Double r4
47 =
new
Point2D.Double(xLeft +
50
,
yTop +
10
);
48
49 Line2D.Double frontWindshield
50 =
new
Line2D.Double(r1, r2);
51 Line2D.Double roofTop
52 =
new
Line2D.Double(r2, r3);
53 Line2D.Double rearWindshield
54 =
new
Line2D.Double(r3, r4);
55
56 g2.draw(body);
57 g2.draw(frontTire);
58 g2.draw(rearTire);
59 g2.draw(frontWindshield);
60 g2.draw(roofTop);
61 g2.draw(rearWindshield);
62 }
63
64
private int
xLeft;
65
private int
yTop;
66 }
115
116
ch03/car/CarViewer.java
1
import
javax.swing.JFrame;
2
3
public class
CarViewer
4 {
5
public static void
main(String[] args)
6 {
7 JFrame frame =
new
JFrame();
8
9 frame.setSize(
300
,
400
);
10 frame.setTitle(
ÐTwo carsÑ
);
11 frame.setDefaultCloseOperation(JFrame.EXIT_ON
12