I have a button that performs a long function, I want to disable this button after the user once clicks on it so that he cannot click it again
The button is disabled, but the problem is that after the function is completed, the button is activated again
I tried to put button.setEnabled(false); to a new stream, but it did not work.
to test this sample code
button.addActionListener(new ActionListener() { @Override public void actionPerformed(ActionEvent ae) { button.setEnabled(false); for (int i = 0; i < Integer.MAX_VALUE; i++) { for (int j = 0; j < Integer.MAX_VALUE; j++) { for (int ii = 0; ii < Integer.MAX_VALUE; ii++) { } } } } });
Steve source share