Problem 1:
Explain the differences between the following:
a)Cartesian coordinates and Java coordinates.
Solution:
Java coordinates default to starting at the upper left
corner of the component. The X's increase from left to right and
the Y's increase from top to bottom. This is different from Cartesian
coordinates where the Y's increase from bottom to top. Also the origin
of Cartesian coordinates is usually in the center of the drawing area with
both positive and negative indexes available.
b)An RGB value and a color.
Solution :
A RGB value is a collection of three numbers that represent the amount of Red Green and Blue mixed together to form a color. A color is a named constant in the Color class that represents a specific color.
c)A graphics context and a component.
Solution :
Every component has a graphics context. A graphics context is represented by an object of the graphics class. A graphics context contains information that is used to draw, such as the current pen color, clip region and drawing mode. A component is an object having a graphical representation that can be displayed on the screen and that can interact with the user.
d)A mouse event and a mouse motion event.
Solution :
A mouse event is created when the user does something with the mouse not involving motion such as clicking buttons, pressing buttons, releasing buttons, and so forth. A mouse motion event is generated when the mouse is either moved or dragged.
e)A public and a protected element.
Solution :
A public element is available to any other class that wants to access it while a protected element is only available to subclasses of the class with the protected element or classes in the same package as the class with the protected element. Both public and protected elements are inherited by subclasses
f)A private and a protected element
Solution :
A private element is only available to objects of the
class that has the private element. A protected element is only available
to subclasses of the class with the protected element or classes in the
same package as the class with the protected element.
Only protected elements are inherited by a subclass,
private elements are not.