[ Team LiB ] Previous Section Next Section

16.6 Exercises

Exercise 16-1. Modify FirstApplet to take advantage of the features of the Graphics class, so that it displays the "Hello World" message in a more visually interesting way.

Exercise 16-2. Modify the Clock applet so that it is configurable via applet parameters, like the Countdown applet is. Your modified applet should read parameters that specify the update frequency for the time display, as well as the font, color, and format of the time display. (See java.text.SimpleDateFormat for a way to format dates and times according to a specified pattern.) Also, add a getParameterInfo( ) method that describes the applet parameters you define, and modify getAppletInfo( ) to include a message describing your contribution to the applet.

Exercise 16-3. Modify the Countdown applet so that it responds to mouse clicks: if the mouse is clicked over the timer, it should reset the time to its initial value.

Exercise 16-4. One of the key features of applets is that they are treated as untrusted code and run under a SecurityManager that prevents them from taking malicious actions such as reading sensitive data, deleting files, or using the client machine to send spam out across the network. Take a look again at Example 7-3 in Chapter 7, and write an applet version of that class that attempts to perform restricted actions. Use a TextField or JTextField component to display the applet's output.

    [ Team LiB ] Previous Section Next Section