swing - Disable button on click before actionPerformed is completed java -


i have button doing long function, want disable button after user once click on in order prevent him clicking again many times

the button gets disabled problem after function finished button gets enabled again
tried put button.setenabled(false); in new thread didn't work either

for testing sample of code

button.addactionlistener(new actionlistener() {     @override     public void actionperformed(actionevent ae) {         button.setenabled(false);         (int = 0; < integer.max_value; i++) {             (int j = 0; j < integer.max_value; j++) {                 (int ii = 0; ii < integer.max_value; ii++) {                 }             }         }     } }); 

use swingworker long running background tasks. in example, startbutton action setenabled(false), , worker's done() implementation setenabled(true).


Comments

Popular posts from this blog

wireshark - USB mapping with python -

c++ - nodejs socket.io closes connection before upgrading to websocket -

Deploying Qt Application on Android is really slow? -