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 ...
Get Sams Teach Yourself Java™ in 24 Hours, Sixth Edition 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.