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

javascript - Laravel datatable invalid JSON response -

java - Exception in thread "main" org.springframework.context.ApplicationContextException: Unable to start embedded container; -

sql server 2008 - My Sql Code Get An Error Of Msg 245, Level 16, State 1, Line 1 Conversion failed when converting the varchar value '8:45 AM' to data type int -