Technical Support
Discussion Forum
Online Training
Technical Articles
Bug Parade
JDC Resources
DukeDollars
Early Access
Toolbar
Community Process
Technology Sites

JDC Home Page

Solaris Developer Connection

Java Technology
java.sun.com

Java Industry Connection

Log Out

Online Training
SearchFAQContact Us

Fundamentals of Swing: Part II
Magercises

By MageLang Institute

[Short Course | About This Short Course]

These Magercises show how to use various aspects of the Model-View-Controller (MVC) architecture of Fundamentals of Java™ Foundation Classes (JFC)/Swing. It helps, considerably, if you have already completed the Magercises from Part I. When you finish the following Magercises, you should have a basic understanding of Swing's MVC architecture and be comfortable working with the more advanced components of the Swing component set.

Magercise Outline

About Magercises

A Magercise is a flexible exercise that provides varying levels of help according to the student's needs. Some students may complete the magercise using only the information and the task list in the Magercise body; some may want a few hints; (Help) while others may want a step-by-step guide to successful completion (Solution). Since complete solutions are provided in addition to help, students can skip a Magercise (or several) and still be able to complete later Magercises that required the skipped one(s).

The Anatomy of a Magercise

Each Magercise includes a list of any prerequisite Magercises, a list of skeleton code for you to start with, links to necessary API pages, and a text description of the Magercise's educational goal. In addition, buttons link you to the following information:
  • Help: Gives you help or hints on the current Magercise (an annotated solution). For ease of use, the task information is duplicated on the help page with the actual help information indented beneath it.
  • Solution: The <applet> tag and Java™ source resulting in the expected behavior.
  • API Documentation: A link directly to any necessary online API documentation.

Magercise Design Goals

There are three fundamental magercise types that you may encounter:
"Blank screen"
You are confronted with a "blank screen" and you create the entire desired functionality yourself.
Extension
You extend the functionality of an existing, correctly-working program.
Repair
You repair undesirable behavior in an existing program.

To make learning easier, Magercises, where possible, address only the specific technique being taught in that Magercise. Irrelevant, unrelated, and overly complex materials are avoided.

Where possible, Magercises execute via the web. However, Magercises that must access JavaTM features or library elements that could cause security violations are not executed on the web.

Magercises, Swing: Part II

1. Tree Views

Create a hierarchy view of a few Java class names.

Educational goal(s):

  • Learn about the JTree, TreeNode, and DefaultMutableTreeNode classes
  • Listen for tree event types
  • Examine the JScrollPane panel

2. Custom JTree Rendering

Create a hierarchy view of a few Java class names and supply a custom node view.

Educational goal(s):

Implement a custom TreeCellRenderer

3. Using JTextPane

Work with the javax.swing.text package to support changing font style, color, size, and family. Use the Swing Chooser classes.

Educational goal(s):

  • Learn about JTextPane, DefaultStyledDocument, and Style
  • Work with JColorChooser and JFileChooser
  • Add icons to menu items
  • Add icons to text panes

4. Using JTable

Work with the javax.swing.table package to create a table with a custom cell renderer.

Educational goal(s):

  • Learn about JTable, TableColumn, and TableCellRenderer
  • Create a custom cell renderer for a table column

Copyright © 1998-1999 MageLang Institute. All Rights Reserved.





Questions?
7-Apr-99
Copyright © 1996-1999 Sun Microsystems Inc.
All Rights Reserved. Legal Terms. Privacy Policy.
Sun Microsystems