O'Reilly logo

Java™ After Hours: 10 Projects You'll Never Do at Work by Steven Holzner

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Creating the Rink

Like the Aquarium application, where the tank was created in the constructor, the hockey rink is created in Slapshot!'s constructor. Some of this constructor will be familiar from the Aquarium project in the previous chapter, but there's a lot more going on here.

To let the user select options—starting a game, ending one, setting the speed, and so on—this application uses a menu system. After creating a menu bar, the code creates a File menu and stocks it with items such as Start, End, Set Speed…, and Exit. These menu items are connected to the code using an action listener, which means the Slapshot class must implement the ActionListener interface and add an actionPerformed method to handle menu selections. The menu items are ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required