CIS 6930-01 – Fall 2000 Part 2: Introduction to the Java Language III. GUIs and Events

12/11/2000


Click here to start


Table of Contents

CIS 6930-01 – Fall 2000 Part 2: Introduction to the Java Language III. GUIs and Events

Getting Started (and Getting Stopped)

GUI Components and Events

AWT vs. Swing

Creating a Frame

Simplest Test of the JFrame Class

Running FrameTest

Trying to Terminate FrameTest. . .

. . . the Window Vanishes, but . . .

What Happened?

Threads and Termination

The Event-dispatching Thread

Strategy for Termination

The WindowListener Interface

A Simple Listener Class

A Windowing Program that Terminates

Simple Use of Swing Components

Internal Structure of a JFrame

Swing Component Hierarchy

Atomic Components and Containers

A Panel with Buttons

Action Listeners

Event Model Illustrated with Button

Handling Events in the Button Panel

Handling Events from Multiple Sources

Completing ButtonTest

Running ButtonTest

Running ButtonTest

Running ButtonTest

Check Boxes and Radio Buttons

Adding a Check Box to a Panel

Running CheckBoxTest

Running CheckBoxTest

Running CheckBoxTest

Running CheckBoxTest

Running CheckBoxTest

Adding a Radio Button Group to a Panel

Handling Radio Button Events

Running RadioButtonTest

Running RadioButtonTest

Running RadioButtonTest

Model-view-controller Design Pattern

The ButtonModel Interface

The Text Field Component

Document Listeners

Adding Two Text Fields to a Panel

Running TextFieldTest

Running TextFieldTest

Running TextFieldTest

Dialog Boxes

A Panel that Uses a Dialog

Running DialogueTest

Running DialogueTest

Running DialogueTest

Running DialogueTest

Running DialogueTest

JOptionPane

Editing Larger Areas of Text

Scroll Panes

Scroll Bar Policies

A Panel with a Scrollable Text Area

Text Area Example

Running TextAreaTest

Running TextAreaTest

Lists

Adding a Static List to a Panel

Running ListTest

Running ListTest

Running ListTest

Responding to Selections

Listening for List Selection Events

Handling List Selections

Running ListTest

Running ListTest

Dynamic Lists

The Default List Model

Adding a Changeable List to a Panel

Changing the List Contents

Running DefaultListModelTest

Running DefaultListModelTest

Running DefaultListModelTest

Not Listening

Menus

Adding a Menu Bar to a Frame

Running MenuTest

Running MenuTest

Running MenuTest

File Choosers

Using a File Chooser

File Chooser Example

Running FileChooserTest

Running FileChooserTest

Running FileChooserTest

Running FileChooserTest

Running FileChooserTest

Running FileChooserTest

Miscellaneous other Components

A Candy Combiner

More Information

Layout and other Stylistic Issues in Swing

Layout of Components in a Panel

Some Available Layout Managers

Using BorderLayout

Using FlowLayout

Using GridLayout

Using BoxLayout

Fillers in Box Layout

Hierarchical Use of Layouts

Miscellaneous other Stylistic Features

Borders

BorderFactory

A Panel With a Bordered Group

Running BorderTest

Labels

Running LabelTest

Features of Alignment (JDK 1.2.2)

Use of Icons

Adding Icons to Menu Items

Running IconTest

Tool Tips

Running ToolTipTest

Events Revisited

The Event Dispatching Thread

Avoiding Interference

Initialization

Using the Event-Dispatching Thread

Low Level Events

Keyboard Events

Typing “A”

Mouse Events

Listening for Mouse Motion

Methods for Mouse Events

Low-level Graphics

Custom Graphics

Graphics is Event-Driven

Changing Graphics: the repaint() method

The java.awt.Graphics class

Some Methods for Drawing

The java.awt.Font Class

The FontMetrics Class

The java.awt.Color Class

Images

Drawing Images

Image Downloading: MediaTracker

The Graphics2D Class

The Paint Interface for Filling Objects

The Stroke Interface for Lines

Shapes

Graphics2D drawing methods

Author: Neil Jasper

Email: dbc@csit.fsu.edu

Home Page: http://aspen.csit.fsu.edu/it1fall00