Java Tutorial 1999 Part 3: Graphics, the Abstract Windowing Toolkit, and the Swing Set

10/21/99


Click here to start


Table of Contents

Java Tutorial 1999 Part 3: Graphics, the Abstract Windowing Toolkit, and the Swing Set

Applets and Graphics

The java.awt.Graphics class

Methods for drawing in the Graphics Class

The java.awt.Font and FontMetrics Class

FontMetrics class

The java.awt.Color Classes

Graphics Examples

The Graphics2D class

The Paint interface for filling objects

The Stroke interface for borders and lines

Shapes

Graphics2D drawing methods

Applet methods

Graphics is Event-Driven: paint method

Changing Graphics: repaint method

Introducing a Single Thread

Introduction to Threads

Example showing the standard thread methods

Example showing thread methods, continued

Motion (or Animation) Example using threads and parent/child hierarchy

Designing the Classes

The Class Hierarchy of this example

Images and Double Buffering

Getting Images Downloaded

Drawing Images to the applet window

ImageIcon class in Java2

Image Downloading -- imageObserver, MediaTracker

An Image Drawing Example

Flickering in Applets and its Solution

The default Update(Graphics g) Method

Double Buffering to Reduce Flicker - I

Double Buffering to Reduce Flicker - II

Double Buffering

Abstract Windowing Toolkit (AWT):

AWT GUI Components

Top Levels of the Component Hierarchy

AWT vs. Swing Components

AWT Components

Picture of the AWT Component Class and some of its inheritance

Basic AWT Components

Basic AWT Component: Label

Basic AWT Component: Button

The AWT Event Model

Event Model illustrated with Button

Setting up ActionEvents for a Button

The Event Classes

AWT Components -- Text Fields & Areas

AWT Components -- Checkbox

Some Further AWT Components -- typical subunits of panels

Keyboard and Mouse Events

Key Events

Mouse Events

Additional Mouse Event handler methods

Methods for Mouse Events

Using Mouse Events for User Interaction

Adapter Classes

Separating GUI and Application Code

Abstract Windowing Toolkit (AWT): Layouts

Layout of Components in a Panel

Brief Description of LayoutManagers

Description and Example of BorderLayout

FlowLayouts in detail

GridLayouts

BoxLayouts in Java 2

BoxLayout fillers in Java2

Hierarchical Use of Layouts

Abstract Windowing Toolkit (AWT): Swing Components and More Components of the AWT

The AWT and Swing Hierarchy

Internal Structure of a JFrame

Swing Component Hierarchy

JLabel

JButtons

JTextField and JTextArea

JCheckBox and JRadioButton

JComboBox

JLists

AWT Component: Canvas

Some Further AWT Components: Window (Frame and Dialog)

Further methods and events for Windows

Frames can have MenuBars

More on Menus

Dialog Boxes

New Components: ScrollPanes and PopupMenus

Author: Neil Jasper

Email: njm@npac.syr.edu