Task: Write a Colour Chooser Applet that allows the user to choose a colour to be displayed,
using the scrollbars or by entering the values directly. The applet should check that the user has not inputted invalid
values. Figure 9.21, “The Colour Chooser Applet Exercise” shows my user-interface and you can see it working here -
ColorChooserApplet.html
.
Hints: Use a Canvas
object for the coloured rectangle. Initially get the applet
working with the scrollbars only and then try the text fields. The text fields are tricky as the user could
enter something like "asdf". Fortunately the Integer
class constructor that accepts
a String
parameter throws a NumberFormatException
when an invalid
value is passed.
© 2006
Dr. Derek Molloy
(DCU).