5.1 The ImageButton class does not fully conform to the essential requirements of the Component class, for example it does not supply appropriate setSensitive() actions. Review the required actions of a Component, decide upon an appropriate behaviour for an ImageButton and extend the class to implement the behaviour. For example an ImageButton's Image might be converted to grey scale, as in Exercise 4.6 and then have its contrast reduced when it is set insensitive.
5.2 The Applet showStatus() action takes a single String argument and displays it somewhere in the Applet's window, for example the place where "applet started" is shown in Figure 4.1. Re-implement the ImageButton class so that it encapsulates the identity of the Applet it is running within as it is constructed and then displays a short message in this area when the mouse pointer enters it and clears the area when it leaves.
5.3 The Pen Up and Pen Down buttons on the SemiDirectInterface are essentially a toggle. Extend the TuttleButton class to provide a ToggleTuttleButton class which will toggle between two images when it is pressed. Replace the two TuttleButton s on the SemiDirectInterface with a single ToggleTuttleButton.
5.4 The two color panels on the SemiDirectInterface are essentially radio buttons. Extend the TuttleButton class to provide a CheckboxTuttleButton which has a Status attribute and visual indicator. Replace the TuttleButtons on the interface with CheckboxTuttleButtons.
5.5 The interface as presented in this chapter will only allow the tuttle to be moved 25 steps at a time or turned 15o at a time. Devise and design a semi-direct interface which will allow the user to move or turn the tuttle an arbitrary number of steps or degrees. For example one possibility is to have a set of large buttons which move or turn 10 units and a set of small buttons which move or turn 1 unit. So if the user wanted to turn the tuttle 47o to the right they could press the large turn right button 4 times and the small turn right button seven degrees.
5.6 Extend the SemiDirectTuttle interface to add controls for the GeometricTuttle class from Exercise 4.4.
5.7 Experiment with different groupings of the controls. For example the foreground and background controls can be added as vertical rows of TuttleButtons, to the left and right of the tuttle. Where they would occupy the East and West locations of the BorderLayout management policy.
Table of Contents.
Summary of Chapter 5