Why it won't work:

1. The two mouse clicks are two separate events

2. Event 1 calls your fireActionPerformed, which disables the button, calls
the real fireActionPerformed, then enables the button again.

3. Event 2 still causes things to happen, because the events are stored in a
queue, acted on in order.. So by the time the system comes to process event
2, the last bit of event 1 has re-enabled the button.

(Please correct me if I am inaccurate with that.)

How it might work depends on what happens as a result of pressing the
button. For example, say it shows a frame. Get your listener to detect when
the frame is opened and closed. Don't allow more frames to be opened if
there is one open already.

    -----Original Message-----
    From: Vincent Vandenschrick <[EMAIL PROTECTED]>
    To: [EMAIL PROTECTED] <[EMAIL PROTECTED]>
    Date: Wednesday, June 06, 2001 03:13
    Subject: Button multiple "fireActionPerformed"


    Hi list,

    I appologize if the question has already been asked and answered. It
seems to be very simple but I can't figure out how to do it.

    I have a JButton with an action listener registered. The goal is to
prevent a "multiple click" on the button to multiply the
"fireActionPerformed".
    My first idea was to override the fireActionPerformed method to first
disable the button, really fireActionPerformed and then re-enable the
button. This doesn't work since the multiple cliks seem to be forwarded to
the eventDispatchThread before the button gets disabled.

    Did any one ever solve this problem ?
    Thanks for all your answers.

    Vincent.


_______________________________________________
Swing mailing list
[EMAIL PROTECTED]
http://eos.dk/mailman/listinfo/swing

Reply via email to