Exercises

To extend your knowledge of the subjects covered today, try the following exercises:

  • Create an application that uses FocusListener to make sure that a text field's value is multiplied by -1 and redisplayed any time a user changes it to a negative value.

  • Create a simple calculator that adds the contents of two text fields whenever a button is clicked and displays the result as a label.

Where applicable, exercise solutions are offered on the book's Web site at http://www.java21days.com.

Get Sams Teach Yourself Java 2 in 21 Days, Second 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.