I'm using Swing for the first time to create a simple GUI. It consists of a JFrame
upon which I have placed a single JButton
which, when clicked, calls some other code which takes approx. 3 seconds to return.
Just before the call to this code, in actionPerformed()
, I want to update the text on the button to inform the user that processing is occuring. My problem is that the text on the button does not update until after the 3-second call has returned. I want the updated text to be present during the call, then I'll change it back afterwards.
Calling repaint()
on the JButton
doesn't do anything and calling it on the JFrame
results in "Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException
" being thrown when I click the button.