I have a form that includes an area for putting in address information and a table that shows the addresses that have been added. I’ve separated out the ActionListener for the “add address” button on the form into it’s own top level class and I’m finding it tricky and cumbersome to refer back to the form that has the text boxes and the table.
From a design perspective, is it a bad idea to put the class that implements the ActionListener for the add address button as an inner class in the form class? The ActionListener class will be specifically tied to the parent form alone, so I’m figuring that an inner class might be the better route to go. I’m going to perform any business logic outside of the form class, of course…
1
Swing listeners are the typical example for inner classes, possibly even the reason that language feature was added. So go ahead and implement it like that. From the design perspective, the action listener behaviour is really part of the form.
2