Java Reference
In-Depth Information
Programmers note
Java documentation refers to elements that use the underlying APIs
asheavyweightcomponentsandthosethataretotallyimplementedin
Javacodeaslightweightcomponents.InthissensetheAWTconsists
ofallheavyweightcomponents.TheSwingcomponents,ontheother
hand, are mostly lightweight.
A mechanism called “peers” facilitated the development of the original
Java toolkits and gave applications the look-and-feel of their host operat-
ingsystem.However,theuseofpeersbringsaboutaperformancepenalty
for Java applications and has been the source of bugs and system
dependecies. Java 1.2 addressed these problems by means of a new set of
APIs called Swing.
In contrast with API components, Swing components are designed to
work the same on all platforms. Swing components add functionality to
the AWT methods. The swing interface makes it possible to select an ap-
plication's “look and feel.” For example, a program using Swing compo-
nents can look like a Win32, a Motif, or a Mac program. In addition swing
implements a new graphics rendering paradigm called a
Model-View-Controller (MVC) architecture. In this scheme each compo-
nent has an associated Model class and an interface it uses. In this topic
graphics coverage is restricted to the AWT. We do not cover swing.
Java 2D
Java 2D is the name of an extension of the AWT that includes enhanced
graphics, text operations, image handling, color definition and composi-
tion,hitdetection,anddevice-independentprinting.TheclassGraphics2D,
whichextendstheAWTGraphicsclass,isthefundamentalclassofJava2D.
Applications that use Java 2D functionality start by creating an object
of the Graphics class, then casting it into one of the Graphics2D classes.
The result is that the methods of both classes, Graphics and Graphics2D,
become accessible to code. In this topic you will see how the Graphics
and Graphics2D classes are used to implement GUIs and graphics output.
Java proposes to be a portable language, but the graphics platforms
present the biggest challenge to this portability. The hardware variations
and the uniqueness of the various operating systems result in GUIs with
substantial differences. Windows, Macintosh, xWindows, and Motif,
among others, present individualities that are often difficult for Java to
accommodate. The Java AWT provides facilities for manipulating images
Search WWH ::




Custom Search