动画线程和EDT

动画线程和EDT,第1张

动画线程和EDT

SuspendedAnimation.run()
您的内心 并不
在EDT上。那是您需要使用的地方
invokeLater()
,而不是在调用
Animate()

@Overridepublic void run(){    // We're outside the EDT in most of run()    m_IsAnimationNeeded = true;    for (JPanelRailoadSquare currRailoadSquare: m_PlayerRailoadPanelsTrack)    {        SwingUtilities.invokeAndWait(new Runnable() { // The pre that "talks" to Swing components has to be put on // the EDT currRailoadSquare.SetGoingTrain(); repaint();        });        // We want to keep sleeping outside the EDT.        try        { Thread.sleep(150);        }        catch (InterruptedException e){}        SwingUtilities.invokeAndWait(new Runnable() { currRailoadSquare.UnSetGoingTrain(); repaint();         }    }}


欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/zaji/5431023.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-12-11
下一篇 2022-12-11

发表评论

登录后才能评论

评论列表(0条)

保存