Java Academy

7/24/98


Click here to start


Table of Contents

Java Academy

Part II: Intermediate Java

Java Fonts

The Font Object

Font Name

Font Style

Font Size

Font Metrics

FontMetrics Object

The drawString Method

AppletDemo.java

Java Font Model

The stringWidth Method

Centering a String Horizontally

Centering a String Vertically

Centering Two Strings

Centering n Strings

Working With Color

RGB Color Format

Hexadecimal RGB Values

Color Parameters

Color Constants

Comparing Colors

Storing and Accessing Colors

Two-dimensional Array

Nested Loops

A Hashtable of Colors

The SystemColor Class

An Observation

Object-Oriented Geometry

Object-Oriented Programming

Multiple Classes

TriangleTest.java

A Triangle Class

Multiple Constructors

No-argument Constructor

Another Constructor

Another Constructor (cont’d)

Instance Methods

Instance Methods (cont’d)

Triangle Class Revisited

TriangleTest Applet

TriangleTest Applet (cont’d)

Reusable Classes

Multiple Source Files

Quadrilateral Class

Quadrilateral Constructor

QuadrilateralTest.java

Another Example

The Point Class

The Octagon Class

An Octagon Constructor

The addPoint Method

Overloading a Method

The Octagon Constructor Again

A Different Approach

A Subclass of Polygon

The Hexagon Class

The MyPolygon Class

Graphical User Interfaces

GUI Components

Labels

Buttons

The ActionEvent Class

Java Interfaces

The ActionListener Interface

Handling Button Events

The addActionListener Method

ButtonTest.java

The actionPerformed Method

Delegation Event Model

Text Fields

A Separate Event Handler

The TextFieldHandler Class

Handling TextField Events

A Flexible Constructor

Listening for TextField Events

TextFieldTest.java

Text Areas

TextArea Constructors

TextArea Scrollbars

TextArea Scrollbars (cont’d)

TextAreaTest.java

Item Events and Listeners

Events and Listeners Compared

Checkboxes

Checkbox Constructors

The ItemListener Interface

An Array of Checkboxes

Processing the Checkboxes

Handling Item Events

The CheckboxGroup Class

Creating a CheckboxGroup

Handling CheckboxGroup Events

The Choice Class

The addItem Method

Handling Choice Events

AWT Scrollbars

The Scrollbar Constructor

Scrollbar Properties

Scrollbar Events

AdjustmentListener Interface

Scrollable Lists

The List Constructor

List Events

Author: Tom Scavo

Email: gcf@npac.syr.edu

Home Page: http://www.npac.syr.edu