Animation Delay - Swing EDT problem

Get new comments by email
You can cancel email alerts at anytime.
Comments (1)

Justin in Auckland, New Zealand

80 months ago

this probably turns out a stupid question, but it's been driving me crazy. so PLEASE help out

Basically what I want is when the sign in button is clicked, the glass pane is turned on, shows some animation and when the rest done, turn it off.

because the rest is alot and so I put it in another thread.

The problem is that when the button is clicked, the classPane is turned on (like I expected), but the animation doesn't start immediately, Its only starts when the rest in another thread has finished (but at that point, the glasspane is already turned off). So what I have is just an image doing nothing and then disapears

This is the code

btnSignIn.addActionListener(new ActionListener()
{
public void actionPerformed(ActionEvent e)
{
//display the glasspane first
setGlassPane(new MyGlassPane(newAnimatedIcon("images/LoginWaitingIcon.png")));

getupGlasPane.setVisible(true); //expected the glassPane shows (it does), and the animation starts (it doesnt)

new Thread(new Runnable() //The animation only starts when this thread finished
{
public void run()
{
//DO THE REST
setupGlasPane(false); //finish, turning off
}
}).start();
});

Is there a way I can force the animation starts immediately before the other thread starts?

Thank you so much

- Was this comment helpful? Yes / No Reply - Report abuse

» Sign in or create an account to comment on this topic.