I have a textfield and a button.
They have identical actionPerformed event listener. (e.g. when user clicks a button and when user hits ENTER).
Is there a way to avoid this kind of duplication of code? It just becomes a pain in the __ modifying the code in 2 places for each such case.
I was thinking would it be possible to call a button event inside of a textfield event, analogous like calling a function inside of another function?
EDIT:
Passing the same addActionPerformed method call to both textfield and button did the trick.