By Tony Bevis on Monday, 23 October 2023
Category: Java

Java programming course: 17.5 Handling the Add button

Handling the Add button

All that remains now is to write some code for the Add button to enable the user to switch from "change" mode back into "add" mode. Go to the Design view of AnimalPanel and double-click the Add button to generate its addButtonActionPerformed() method. All it needs to do is invoke clearAnimal() on the animalEditor instance and clear any selections in the tree:  

That completes the coding for the animal panels, and you should now be able to add, change and remove as many animals as you wish.

Next lesson: 18.1 Finishing off the User Interface

Related Posts

Leave Comments