Java Reference
In-Depth Information
10-11. Modify the
AppletMenuBar
component so that, in addition to displaying
menus, it can also display buttons (i.e., make it work as a combination
menubar/toolbar). Add an
addCommand()
method that is analogous to the
addMenu()
method. Instead of taking a string and a
PopupMenu
, this new
method should take a string label and a
ActionListener
object. If the user
clicks on the specified label, the component should call the
actionPer-
formed()
method of the specified listener. When testing the class, recall
that the
Command
class from Chapter 8 implements the
ActionListener
interface.