Home : Course Map : Chapter 6 : Java : Advanced :
Chapter 6: AWT & Java2D
JavaTech
Course Map
Chapter 6

Introduction
AWT
Swing
Containers
  Demo 1
UI Components
  Demo 2
UI Layout
  Demo 3   Demo 4
Text Display
  Demo 5
Drawing
  Demo 6   Demo 7
Draw Polygons
  Demo 8   Demo 9
Colors
Text Draw 
  Demo 10
Images
  Demo 11
Exercises

    Supplements
AWT
  Demo 1
Drawing
  Demo 2
Text Drawing
  Demo 3
UI Components
  Demo 4

Java2D
Shapes & Areas
  Demo 1   Demo 2
Stroke & Paint
  Demo 3
Transforms
  Demo 4
Gradients&Textures
  Demo 5   Demo 6
Text
  Demo 7   Demo 8
     About JavaTech
     Codes List
     Exercises
     Feedback
     References
     Resources
     Tips
     Topic Index
     Course Guide
     What's New

In these supplements we look at the old and the new in Java graphics techniques:

  • AWT - We first give present an overview of graphics with the basic AWT. This can help to understand the basics on which Swing and Java2D are built. Also, you might need to debug or upgrade an older program or need to do graphics on a minimal platform without Java2D.

  • Java2D - The second part of this supplement section looks at programming with Java2D. Java2D provides lots of advanced graphical tools for drawing, text and image display.

Note: The user interface examples discussed in Chapter 6: Java and in Chapter 7: Java use Swing and are a big step up in functionality and esthetics over basic AWT. However, they are still fairly basic and unadorned. In Chapter 7: Supplements we discussion ways to enhance the appearance of the Swing components and layouts.

AWT

An essential and very popular part of Java has always been its graphical user interface capabilities. Applets, for example, were intended to act as interactive mini-programs within the browser environment and they needed not only to draw pictures and graphs but also to provide for user input and control.

The graphics in versions 1.0 and 1.1 were very limited. Since version 1.2, the standard Java kit provides a far more capable and elaborate set of graphics classes (javax.swing.* ) than the earlier versions. The Swing classes, however, still build upon the lower level classes of the original java.awt.* graphics classes. So it can be of some interest to know more about the AWT (A Windows Toolkit.)

In this section we give a brief introduction to AWT graphics and user interface development. This provides a background for the Swing system but also, since many people still use browsers with a version 1.1 JVM, you might want to program some of your applets with only the AWT classes so that they can work with as many users as possible.

The pages here discuss:

  • Basics of the AWT - component class, paint() method, Graphics context class, drawing commands, and the drawing coordinate system.
  • Simple Drawing - the essentials of graphics drawing methods
  • Text Drawing - drawing text with different sizes and fonts.

We will continue in the Chapter 7 : Supplements : AWT- Part 2 section with additional information on building program interfaces with the AWT.

Java2D

This section provides a brief overview of the Java2D set of graphics tools that became available with version 1.2. Java2D provides a vast increase in graphical capabilities compared to the basic tools available in the standard AWT graphics context.

We give a brief introduction and demonstration applets on the several topics:

  • Java2D introduction
  • Shapes & Areas - rather than drawing each line segment of a particular form, in Java2D a shape object is created and then it draws itself in one operation.
                       Demo 1   Demo 2
  • Transforms - affine transformations provide for translations, rotations, scaling and skewing of the shape objects.
                       Demo 3
  • Strokes & Painting - control line thicknesses, the endpoints, dashed form etc.
                       Demo 4
  • Gradients&Textures - shapes can be filled with gradient colors and image textures.
                       Demo 5  Demo 6
  • Text - Java2D provides lots of text capabilities and you could even create a full text editor from scratch. Here we just look at how to vary the attributes of characters in a string and how to give them a textured filling.
              Demo 7   Demo 8

Most recent update: Oct. 3, 2005

 

 

            Tech
Java Tech Graphics
Starting to Plot
  Demo 1
Drawing Panel
  Demo 2
Histogram Display

  Demo 3
Exercises

           Physics
Display Text Data
  Demo 1
Plot Data
  Demo 2
Find Max/Min
  Demo 3
Exercises

  Part I Part II Part III
Java Core 1  2  3  4  5  6  7  8  9  10  11  12 13 14 15 16 17
18 19 20
21
22 23 24
Supplements

1  2  3  4  5  6  7  8  9  10  11  12

Tech 1  2  3  4  5  6  7  8  9  10  11  12
Physics 1  2  3  4  5  6  7  8  9  10  11  12

Java is a trademark of Sun Microsystems, Inc.