Chapter 15: More Widgets

The exercises here are taken from my forthcoming book The Java Developer's Resource.


  1. What would happen if you tried to set more than one Checkbox in a CheckboxGroup to true initially?


  1. Write a Headline Component which implements the same methods as java.awt.Label but draws all text in 24 point Helvetica bold.
  2. Add two constructors to the PanicButton class. One that takes no arguments and produces a PanicButton with a fifty pixel radius, and one that takes an int and produces a PanicButton with that size radius.
  3. Write a CircleButton class that creates a circular button as a subclass of Canvas. It should allow (but not require) the creator to specify the label and the radius of the button. Furthermore it should post an action event if the mouse is pressed and released inside the circle.
  4. Add getLabel and setLabel methods to the PanicButton class. If the size of the button was not specified at creation time, adjust the minimum size of the button to be large enough for the text in the current font.
  5. Add setColor, setTextColor and setFont methods to the CircleButton. You now have a fairly generic circular button.

[ Exercises | Cafe Au Lait | Books | Trade Shows | Links | FAQ | Tutorial | User Groups ]

Copyright 1996 Elliotte Rusty Harold
Last Modified August 20, 1996