SwingUtilities.invokeLater() [英] SwingUtilities.invokeLater()

查看:253
本文介绍了SwingUtilities.invokeLater()的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的方法的doWork()我称之为

In my method doWork() I call

SwingUtilities.invokeLater(new Runnable(){
public void run() {
button.setBackgroundColor(Color.red);
}
});

然后我打电话

SwingUtilities.invokeLater(new Runnable(){
public void run() {
button.setBackgroundColor(Color.blue);
}
});

问题是否将成为按钮是红色,那蓝色或蓝红色则?

Question whether will be button is red then blue, or blue then red?

推荐答案

的invokeLater()将它的参数来Swing事件队列。所以他们会在它们的添加顺序执行,即先红蓝色然后

invokeLater() adds its parameter to the Swing event queue. so they will be executed in the order they were added, i.e. first red then blue.

这篇关于SwingUtilities.invokeLater()的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆