Exercises for Chapter 3

3.1 Color can be used in the StikNote application to indicate the relative importance of the notes. For example a red note to indicate an important message, yellow for routine and green for non-important. Redesign and re-implement the StikNote application to provide three buttons marked Urgent, Routine and Trivial at the bottom which will produce a note of the required color.

3.2 Following on from exercise 3.1, different fonts can also be used. Use the AWT documentation to find out what fonts are available and use different fonts for different priorities of message.

3.3 Extract the first word, or two, from the contents of a StikNote and use it as the window's title, rather than have them all titled "Stik Note".

3.4 Test the DatePanel. Produce a formal black box test plan and apply it to the component in order to increase your confidence that it is working correctly.

3.5 Place the DatePanel within a realistic application, for example one which asks you to indicate your date of birth and then informs you how many days you have lived.

3.6 Re-design and re-implement the DatePanel so that it has a minimum date below which a date cannot be selected. For example an airline booking system should only allow a return flight to be booked on a date later than, or equal to, the date of the outward flight. Demonstrate the MinimumDatePanel in a suitable harness.

3.7 The DatePanel in this chapter takes up a large amount of screen space. This design attempts to provide the same functionality in a much smaller space. Pressing the appropriate button will increase its field and pressing will decrease it. Design, implement and demonstrate this design. How would you find out which was favored by users?

3.8 Implement a MinimalClockPanel based on the design idea from Exercise 3.7, allowing a time to be specified some time ahead of the current time. Include an instance of it on the StikNote interface allowing an alarm time to be set on the NoteWindow. When the time has arrived the note should indicate this to the user by reversing its colors every half second.

3.9 Re-implement the MessageCanvas class so that it has an attribute and methods to control the layout, LEFT, RIGHT or JUSTIFIED of the message.

3.10 Adapt the DatePanelDemonstration class so that it registers two object listeners with the DatePanel contained within it, then show that both are called when the date is changed.

3.11 There is a bug in the positioning of the NoteWindow instances. If the main StikNote window is in the top left of the desktop, the instance's top left corner may be positioned somewhere beyond the top left corner. Demonstrate and correct this bug.

3.12 The MessageCanvas class is not fully secure or compliant with the pre-declared AWT components. For example it inherits the setFont() method from the Component class which should result in its minimum and preferred sizes changing. Make a list of all the methods which it inherits and decide which need to be overridden in order to make it fully compliant.


Table of Contents.

Summary of Chapter 3




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