Add an actionlistener to your JButton and it will tell you when its been clicked like so:
someButton.addActionListener(new ActionListener(){
public void actionPerformed(ActionEvent e) {
//the button was pressed and do your stuff here.
}
}
3
solved Mouse event handling in Swing