The Author Online Book Forums are Moving

The Author Online Book Forums will soon redirect to Manning's liveBook and liveVideo. All book forum content will migrate to liveBook's discussion forum and all video forum content will migrate to liveVideo. Log in to liveBook or liveVideo with your Manning credentials to join the discussion!

Thank you for your engagement in the AoF over the years! We look forward to offering you a more enhanced forum experience.

This topic is READ ONLY
import-bot (20211) [Avatar] Offline
[Originally posted by sharat]

I have added a MouseListener to a button. I disable the button by setting
button.setEnabled(false). But when I click on the button the handler gets
triggered. Though the button's color is greyed, the handler triggers the
action to be taken. The button is present in a panel.

import-bot (20211) [Avatar] Offline
Re: Mouse Event is triggered inspite of disabling a button
[Originally posted by matt]

In your handling code, check for the enabled state
before processing:

public voic mousePressed(MouseEvent e) {
if (e.getSource() == myButton) {
if (myButton.isEnabled()) {
// your stuff here