Hint: What the ActionListener needs to know

Note that the listener for the Ok button will need to get values from the textfields and the color chooser after the user clicks Ok. So the obvious way to design that listener is to pass to its constructor all of the components that it will need to read.

Notice, though, that all of those components are already grouped together as part of the AddListener. So another way to organize your code would be to make another method on that class for "make a sprite from your components". Then the only thing that the Ok listener needs to know about is that one instance of AddListener.


Cary Gray
Last modified: Wed Apr 15 16:01:25 CDT 2015