Course Notes Table of Contents
Exercises | Online Training Index
Exercises: Swing

Introduction

These exercises show how to use various aspects of the Model-View-Controller (MVC) architecture of Swing. It helps, considerably, if you have already completed the exercises from Part I.

There are 4 exercises to complete:

  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 com.sun.java.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 Tables
    Work with the com.sun.java.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 © 1997 MageLang Institute. All Rights Reserved
May-97 Copyright © 1996, 19 97 Sun Microsystems Inc. All Rights Reserved