Your assignment for this lesson is to write a GUI program that will use a button to count down from five to zero. When i
Posted: Mon Jun 06, 2022 5:39 pm
Your assignment for this lesson is to write a GUI program that will use a button to count down from five to zero. When it reaches zero, it should display a label indicating the end of the count. Each click should decrease the number by one. For example, when the program starts the button will say "Five" or "5." After the first click, it will say "Four" or "4," and so on. When it gets to zero, the button should be replaced by a label with a message in it. The text in the label can say anything you like. There are two things you will need to use that we did not discuss in the lesson. You will need to be able to find out what text was on the button when it was clicked. You can do that with the button's getText() method. You will also need to know how to make a button disappear so you can see the label. A button has a setVisible() method just like a frame does. To make the button disappear, call its setVisible() method with an argument of false.