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

Introduction

These exercises show how to use Java's Swing components to interact with Java forms and windows.

There are seven exercises to complete:

  1. Installation and SwingSet Demonstration
    Install Swing and demonstrate the SwingSet examples.

    Educational goal(s):

    • See the different Swing components in action

  2. A First JFC Application
    Create a simple application with a Frame and a few Swing buttons.

    Educational goal(s):

    • Setup the environment to compile and run Swing programs
    • Examine basic Swing Frame-based application
    • Learn that Swing components can be used just like AWT components
    • Use JDK 1.1 events to respond to button presses

  3. Buttons With Icons
    Create image buttons with keyboard accelerators.

    Educational goal(s):

    • Learn to use an Icon as a JButton label
    • Learn to use keyboard accelerators with buttons
    • Use JDK 1.1 events to respond to button presses
    • Add components to a JFrame

  4. Using Borders
    Change the default border around a JButton and create your own dashed border.

    Educational goal(s):

    • Learn about the com.sun.java.swing.border package
    • Learn to change a button's border
    • Learn to create your own borders

  5. Using Toggles
    Create a program to demonstrate checkboxes and radio buttons.

    Educational goal(s):

    • Learn about the JCheckbox class
    • Learn about the JRadioButton class
    • Learn about using icons with your checkboxes
    • Learn about the JScrollPane class

  6. Using Menus, Toolbars, and Tool Tips
    Setup the menus, toolbar, and toolbar tool tips for a simple text editor.

    Educational goal(s):

    • Learn about JMenu, JMenuItem, and JMenuBar
    • Learn how to work with JToolBar and tool tips
    • Learn about the JDialog class

  7. Using BoxLayout
    Create an application using the BoxLayout layout manager.

    Educational goal(s):

    • Learn about the Box class
    • Learn about the BoxLayout class ("glue" and "struts") and how to use it for simple layouts
    • Learn about using animated ImageIcon objects



Copyright © 1997 MageLang Institute. All Rights Reserved
May-97 Copyright © 1996, 1997 Sun Microsystems Inc. All Rights Reserved