Swing Repainting JButton

by GarciaPL on Monday 2 March 2015

At my currently project written mainly in Swing, I had an issue where there was a need to show some text on JButton before some calculations. Unfortunately after setting some custom text on this component using .setText method, I was invoking some quite heavy operations which blocks UI. I tried using .repaint and .revalidate methods (once on component, once on RootPane) before those operations, but they did not work. Finally, I managed to obtain how to force change this text using method paintImmediately.

getButtonLogin().paintImmediately(0, 0, 600, 600)