Mouse event handling in Swing

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.
    }
}

Leave a Comment