Skip to content
Advertisement

ActionListener knowing which component triggered the action

I would like to have an actionlistener to be able to figure out the source as shown in the code below. How should i implement this?

JavaScript

How do i tell code such that my action listener will be able to know exactly which jtextfield is triggering this action?

Advertisement

Answer

ActionEvent#getSource() returns the object (component) that originated the event:

JavaScript
User contributions licensed under: CC BY-SA
7 People found this is helpful
Advertisement