CS 121 Lecture 41: The Polygon Class

22 views5 pages

Document Summary

The polygon class: object can explicitly define a polygon. Defined in the java. awt package of the java standard class library. Two versions of the overloaded drawpolygon & fillpolygon methods take a single polygon object as a parameter. Polygon object encapsulates coordinates of the polygon sides. Constructors allow creation of an initially empty polygon or one defined by the arrays of integers representing the point coordinates. Methods: polygon() constructor: creates an empty polygon, polygon(int[] xpoints, int[] ypoints, int npoints) . When you click the mouse button over a java gui component, 3 events are generated: mouse pressed: when the mouse button is pushed down, mouse released & mouse clicked: when it is let up. Mouse click: pressing & releasing the mouse button in the same location: if you press the mouse button down, move the mouse, & then release the mouse button, a mouse-clicked event is not generated.

Get access

Grade+20% off
$8 USD/m$10 USD/m
Billed $96 USD annually
Grade+
Homework Help
Study Guides
Textbook Solutions
Class Notes
Textbook Notes
Booster Class
40 Verified Answers
Class+
$8 USD/m
Billed $96 USD annually
Class+
Homework Help
Study Guides
Textbook Solutions
Class Notes
Textbook Notes
Booster Class
30 Verified Answers

Related Documents

Related Questions