How can I detect when a JRadioButton is changed from 'unselected' to 'selected' when clicked with the mouse? I've tried using an ActionListener on the button, but that gets fired every time the radiobutton is clicked, not just when it's changing state to 'selected'.
I've thought of maintaining a boolean variable that remembers the state of the button, and test it inside the ActionListener to see whether to change its state but I'm wondering if there's a much better or cleaner solution.