Java Reference
In-Depth Information
Chapter 6
Java graphics
6.1 Introduction
Java's graphics capability has always been a leading feature of the language.
The Java designers clearly expected the graphical user interface (GUI) to dom-
inate interactions with Java programs on all but the smallest platforms. Java
appeared at the start of the Internet boom and applets were expected to bring
interactivity to the browser. Many thought that Java would also quickly become
popular for standalone client applications on platforms with graphical operating
systems.
In Java 1.0, however, the graphical elements provided for workable interfaces
but they appeared crude compared to platform-specific graphics developed with
other languages. The goal of portability had led to a lowest common denom-
inator approach that was not very pretty. This became one of the main stum-
bling blocks that prevented Java from becoming a popular language for desktop
applications.
However, with the inclusion of the Swing packages in version 1.2, Java graphics
took a huge leap forward in visual appeal and in the breadth and depth of its
features. With subsequent versions, Java graphics continued to improve and now
compares quite well with that available with any other programming language
and still provides for relatively easy portability.
In this chapter we introduce Java graphics starting with a quick overview of the
Abstract Windowing Toolkit from Java 1.0. We then look at the Java Foundation
Classes system, also known as “Swing,” in some detail. We wait until Chapter 7
to discuss how to bring interactivity to the user interface. This chapter focuses
on using Swing components, drawing on Swing panels, and displaying text and
images. We use the display of histograms as an example of a technical application
of Java graphics.
We do not have space here to provide in-depth descriptions of all the capabil-
ities of the many graphics related classes. We focus on the fundamental features
of the visual components and illustrate their use in demonstration programs. See
the Web Course Chapter 6 and the Java 2 API specifications and the references
for more information about Java graphics resources.
160
Search WWH ::




Custom Search