Dynamic updates in a Component

From: jac (jac_at_ai.com)
Date: 02/24/04


Date: Tue, 24 Feb 2004 22:13:44 GMT

Hi to all,
I don't understand how to dynamically update the visualization of a
component, that is:
I need to change the icon of a JButton and during the execution of the
program it may change more times (two or three [see sample code]). What I
see is only the last change. I tryed updateUI() method or similar without
result.
What could I do to view the middle change?

Thanks

<-----start here----->
button1.setIcon(new ImageIcon("images/img1.JPG"));
...
try{ Thread.sleep(1000); }
catch (InterruptedException ex) {}
button1.setIcon(new ImageIcon("images/img2.JPG"));
...
try{ Thread.sleep(1000); }
catch (InterruptedException ex) {}
button1.setIcon(new ImageIcon("images/img3.JPG"));

<-----end here----->