当前位置: 技术问答>java相关
Java中的SwingUtilities有什么用啊!
来源: 互联网 发布时间:2015-01-02
本文导语: 我在一个程序中常看见SwingUtilities.invokeLater()方法的调用,他是另外启动一个线程吗?为什么另外启动线程会是这样呢? | As far as I know, all repainting is done by the AWT-Event-Queue. However, you c...
我在一个程序中常看见SwingUtilities.invokeLater()方法的调用,他是另外启动一个线程吗?为什么另外启动线程会是这样呢?
|
As far as I know, all repainting is done by the AWT-Event-Queue.
However, you can't join to this thread as it will never finish.
Any updates you do to to GUI should be done in the event thread
by using SwingUtilities.invokeLater or
SwingUtilities.invokeAndWait.
For example, in the thread that draws onto the panel:
SwingUtilities.invokeLater( new Runnable() {
public void run() {
// do your drawing stuff here
}
});
However, you can't join to this thread as it will never finish.
Any updates you do to to GUI should be done in the event thread
by using SwingUtilities.invokeLater or
SwingUtilities.invokeAndWait.
For example, in the thread that draws onto the panel:
SwingUtilities.invokeLater( new Runnable() {
public void run() {
// do your drawing stuff here
}
});