Java Reference
In-Depth Information
΢GExercise P9.14. Enhance the ButtonViewer program so that it prints a
message ȒI was clicked n times!ȓ whenever the button is clicked. The value
n should be incremented with each click.
΢΢GExercise P9.15. Enhance the ButtonViewer program so that it has
two buttons, each of which prints a message ȒI was clicked n times!ȓ
whenever the button is clicked. Each button should have a separate click
count.
΢΢GExercise P9.16. Enhance the ButtonViewer program so that it has
two buttons labeled A and B, each of which prints a message ȒButton x
was clicked!ȓ, where x is A or B.
΢΢΢GExercise P9.17. Implement a ButtonViewer program as in Exercise
P9.16, using only a single listener class.
΢GExercise P9.18. Enhance the ButtonViewer program so that it prints
the time at which the button was clicked.
΢΢΢GExercise P9.19. Implement the AddInterestListener in the
InvestmentViewer1 program as a regular class (that is, not an
inner class). Hint: Store a reference to the bank account. Add a
constructor to the listener class that sets the reference.
΢΢΢GExercise P9.20. Implement the AddInterestListener in the
InvestmentViewer2 program as a regular class (that is, not an
inner class). Hint: Store references to the bank account and the label in
the listener. Add a constructor to the listener class that sets the
references.
΢΢GExercise P9.21. Write a program that uses a timer to print the current
time once a second. Hint: The following code prints the current time:
Date now = new Date();
System.out.println(now);
The Date class is in the java.util package.
Search WWH ::




Custom Search