Используйте getSource () , чтобы проверить, какой компонент вызвал событие.
final JButton b = new JButton("Button");
final JTextField f = new JTextField("TextField");
ActionListener l = new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
if (e.getSource() == b) {
/* button fired the event */
}
if (e.getSource() == f) {
/* text field fired the event */
}
}
};
b.addActionListener(l);
f.addActionListener(l);