Setting the Speed

To let the user set the value in the speed variable, Slapshot! uses the dialog box shown in Figure 2.2; the user can even open and use this dialog box when the game is playing.

Figure 2.2. The Slapshot! application's dialog box.

This dialog box is opened when the user selects the Set Speed… menu item, menuitem2. In the actionPerformed method, this item simply displays the dialog box textDialog, an object of the OkCancelDialog class that was created in Slapshot!'s constructor. The user enters the new speed in the text field in the dialog box, which Slapshot! can recover using the dialog box's data member, converting the text the ...

Get Java™ After Hours: 10 Projects You'll Never Do at Work now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.