HCI/JAVA SWING PROGRAMMING
Lab Worksheet 5
Swing Menus

Dr. A.D. Marshall

Aims and Objectives

After Working through the exercises on this worksheet you are expected to:

You are expected to make use of the online Swing reference documentation (http://www.cs.cf.ac.uk/Swing/doc/api/, the recommended course books and other online sources to complete the exercises below.

You may use the programs discussed in lectures and available online as templates to solving the programming exercises below.

NONE of the exercises below count to awards the formal coursework assessment of this module.

Note:

The Exercises below are intended to provide a basis with which you can investigate and study the complete Swing Component classes that there is not enough time (or indeed are not suitable) to address in the lectures. The material is also intended to provide some possible discussion in the tutorials and furthermore provide pointers for additional reading outside of the lectures and tutorials.

You are not expected to cover all the exercises in a single 1 hour tutorial. You are advised to attempt at least a few of the programming exercises in the tutorial -- as programming assistance will be readily available. You may also wish to use some of the tutorial time to access the online reference material. You are expected to access the online reference material as part of the self-study aspect of this module.

Exercises

Further Reading/ Reference Exercises

1.
With reference to the online documentation and/or appropriate text books find out the complete set of properties, methods for the JMenu, JMenuBar, JMenuItem, JPopupMenu and JToolBar classes
2.
What is the appropriate position of each of the above classes in the Swing menu class hierarchy?

3.
What is the function of the JCheckBoxMenuItem and JRadioButtonMenuItem classes? How should they be used in conjunction with other Swing menu classes?

Programming Exercises

1.
Try replacing the setJMenuBar() call in SimpleMenu.Java program example in the lecture notes with this line: topPanel.add( menuBar, BorderLayout.SOUTH );

What is the effect of this change?

2.
Compile and run the RadioButtonmenu example in the /well/dave/Java/Swing/Lecture_Examples directory or available online. Examine the program and note how the important JRadioButtonMenuItem methods and properties are used.

3.
Compile and run the CheckBoxMenu example in the /well/dave/Java/Swing/Lecture_Examples directory or available online. Examine the program and note how the important JCheckBoxMenuItem methods and properties are used.

4.
Create a simple menu application that enables a user to select one of the following items :

(a)
from the menubar of the application
(b)
from a pop-up menu
(c)
from a toolbar

Add tooltips to each menu item that indicates some information about the Radio station such as type of music and its broadcast frequency.

5.
Create a simple menu application that enables a user to select any number of the following items:

(a)
from the menubar of the application
(b)
from a pop-up menu
(c)
from a toolbar

About this document ...

HCI/JAVA SWING PROGRAMMING
Lab Worksheet 5
Swing Menus

This document was generated using the LaTeX2HTML translator Version 97.1 (release) (July 13th, 1997)

Copyright © 1993, 1994, 1995, 1996, 1997, Nikos Drakos, Computer Based Learning Unit, University of Leeds.

The command line arguments were:
latex2html -split 0 -no_navigation Lab5.tex.

The translation was initiated by Dave Marshall on 3/3/1999


Dave Marshall
3/3/1999