O'Reilly logo

Sams Teach Yourself Java™ in 24 Hours, Sixth Edition by Rogers Cadenhead

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

Completing a Graphical Application

To see how Swing’s event-handling classes work in a Java program, you finish LottoMadness, the lottery simulation begun during Hour 14, “Laying Out a User Interface.”

At this point, LottoMadness is just a GUI. You can click buttons and enter text into text boxes, but nothing happens in response. In this workshop, you create LottoEvent, a new class that receives user input, conducts lotto drawings, and keeps track of the number of times you win. When the class is complete, you add a few lines to LottoMadness so that it makes use of LottoEvent. It often is convenient to divide Swing projects in this manner, with the GUI in one class and the event-handling methods in another.

The purpose of this application is ...

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