Java Reference
In-Depth Information
In Java, a programmer uses the Color class, which is part
of the java.awt package, to define and manage colors. Each
object of the Color class represents a single color. The class
contains several instances of itself to provide a basic set of
predefined colors. Figure 2.10 lists the predefined colors of
the Color class. It also contains methods to define and man-
age many other colors.
KEY CONCEPT
The Color class contains several
predefined colors that are commonly
used, and can be used to define
many others.
SELF-REVIEW QUESTIONS (see answers in Appendix N)
SR 2.38 How can a black and white picture be represented using 1s and 0s?
SR 2.39 Three corners of a rectangle drawn using the Java coordinate system
have coordinates (3, 4), (3, 7), and (8, 7). What are the coordinates of
the fourth corner?
SR 2.40 Two corners of a square drawn using the Java coordinate system have
coordinates (5, 10) and (8, 10). What are the coordinates of the other
two corners?
SR 2.41 How many bits are needed to store a color picture that is 300 pixels wide
and 200 pixels high? Assume color is represented using the RGB technique
described in this chapter and that no special compression technique is used.
2.8 Applets
There are two kinds of Java programs: Java applets and Java
applications. A Java applet is a Java program that is intended
to be embedded into an HTML document, transported
across a network, and executed using a Web browser. A Java
application is a stand-alone program that can be executed
using a Java interpreter. All programs presented thus far in
this topic have been Java applications.
The Web enables users to send and receive various types of media, such as text,
graphics, and sound, using a point-and-click interface that is extremely convenient
and easy to use. A Java applet was the first kind of executable program that could
be retrieved using Web software. Java applets are considered just another type of
media that can be exchanged across the Web.
Though Java applets are generally intended to be transported across a network,
they don't have to be. They can be viewed locally using a Web browser. For that
matter, they don't even have to be executed through a Web browser at all. A tool
in Sun's Java Software Development Kit called appletviewer can be used to interpret
and execute an applet. We use appletviewer to display applets in this topic. However,
KEY CONCEPT
Applets are Java programs that are
usually transported across a network
and executed using a Web browser.
 
Search WWH ::




Custom Search