12.7 Programming Activity 1: Working with Buttons

In this activity, you will work with two Buttons that control a simulated electrical switch. Specifically, you will write the code to perform the following operations:

  1. If the user clicks on the “OPEN” button, open the switch.

  2. If the user clicks on the “CLOSE” button, close the switch.

The framework for this Programming Activity will animate your code so that you can check its accuracy. Figures 12.8 and 12.9 show the application after the user has clicked the button labeled “OPEN” and the button labeled “CLOSE,” respectively.

Figure 12.8User Clicked “OPEN”

Figure 12.9User Clicked “CLOSE” ...

Get Java Illuminated, 5th 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.