posted 18 years ago
OK, really simple question, but bizarrely I can't seem to find any examples online...
Given:
JButton button1 = new JButton("One");
button1.addMouseListener(this);
JButton button2 = new JButton("Two");
button2.addMouseListener(this);
and then:
public void mousePressed(MouseEvent e) { }
How do I determine whether MouseEvent e was triggered by button1 or button2? I know how to do it with an ActionListener (giving it a name, and checking it), but I'm specifically interested in the mouse press as opposed to a mouse click for both buttons.
Many thanks in advance,
Chris