Suppose I have a class that creates a window and attaches buttons to this window. That is why I need to create listeners for these buttons. And I decided that the listener would be alone. He will recognize which button was pressed.
But the question is this: What exactly does the getSource() method getSource() ?
public class MyListener implements ActionListener{ @Override public void actionPerformed(ActionEvent ae) { //что хранится в переменной event? Object event = ev.getSource(); //code... } }