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

问题描述

有人能突出显示两者都需要?!

Can someone highlight on the differences between these two and the instances both are required?!

我有同时使用intercheably的应用程序,但想知道,如果一个是优于其他。显然,他们都接受 Runnable对象,所以我 - 我想我可以用我喜欢哪一个

I have an application which uses both intercheably, but want to know if one is better than the other. Obviously they both accept Runnable object, and so for me - I think I can use which one I like.

为什么在不同的班级这两个类似的功能?我知道一个是在AWT和其他Swing,但不要他们做同样的事情?

Why these two similar functions in different classes? I know one is in awt and the other Swing, but don't they do the same thing?

推荐答案

SwingUtilities.invokeLater 只存在,因为 EventQueue.invokelater 1.2推出,但秋千是供1.1。摆在JRE始终只是叫的EventQueue 版本。 swingall.jar 有一些黑客在那里创建一个组件,并执行上重新绘制未决操作。

SwingUtilities.invokeLater exists only because EventQueue.invokelater was introduced in 1.2, but Swing was available for 1.1. Swing in the JRE has always just called the EventQueue version. swingall.jar had some hack where it created a component, and executed pending operations on repaints.

的invokeLater 是关于的EventQueue 。我建议直接使用方法。 的SwingUtilities 只是一个垃圾场。我已经看到了使用 SwingUtilities.invokeLater presumably某种信仰的摇摆不依赖于AWT了不少。

invokeLater is about the EventQueue. I suggest using the method directly. SwingUtilities is just a dumping ground. I have seen a lot using SwingUtilities.invokeLater presumably in some kind of belief the Swing isn't dependent upon AWT.

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

08-19 22:07