Exercises for Chapter 2

2.1 The tables in this chapter provide only a brief overview of the AWT APIs. The most definitive version is in the documentation and source code for the AWT which is provided as part of all Java environments. Consolidate your understanding of the classes in this chapter, and familiarize yourself with the format of this documentation, by reading the entries for the classes discussed.

2.2 Whilst using your IDE to develop Java applets, or any other commercial GUI product (for example your word processor), examine how the various components described in this chapter have been used in panels and dialogs.

2.3 Construct an applet from three Checkbox components configured as radio buttons and a single Label. Each radio button should identify one possible alignment and the Label should change its label and alignment attributes to illustrate the selected button.

2.4 The output from the Scrollbar example is not very well formatted. Re-implement the example so that the decimal value is always three digits long and the hexadecimal value is always two digits long. Hint, revisit the ClickCounter applet from Chapter 1.

2.5 Extend the Scrollbar example to add octal and binary values.

2.6 Adapt the Scrollbar example to implement a Centigrade to Fahrenheit converter with a range of 0oC to 100oC. Unlike the example in this chapter this applet should make use of a separate (application) class to perform the conversion and a separate (translation) listener class to provide its behaviour.

2.7 Extend the Doodle applet to give continuous feedback of the location of the pointer. This will require additional Label components and an extended processMouseMoveEvent() method.

2.8 Implement a TextField which will only allow the input of integer values, any non-digit characters should be removed from the display as soon as the user types them in. Adapt this applet for the input of floating point values which allow a single decimal point.

2.9 Extend the Password applet so that it locks with a suitable message after three unsuccessful attempts.

Table of Contents.

Summary of Chapter 2

A Java GUI programmer's primer
Java GUI Programmers Primer, A
ISBN: 0139088490
EAN: 2147483647
Year: 1998
Pages: 85
Authors: Fintan Culwin

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net