EDT和其他线程关系关于repaint()方法java [英] EDT and other Thread relations regard repaint() method java

查看:71
本文介绍了EDT和其他线程关系关于repaint()方法java的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如果 GUI 确定是由 EDT 构建的,是否会在 EDT 上的其他一些线程调用绘画上进行重绘调用?如果不是,我如何确保它确实如此,效率越高越好.

if the GUI was sure build by EDT does a repaint call on some other Thread invoke painting on the EDT? if not, how do i make sure it does, the more efficient the better.

推荐答案

基本方法 repaint() 默认调用 EDT,一切正常,直到第一次 Thread.sleep(int) 被调用,那么您遇到了 Swing 中的并发性

Basically method repaint() invoke EDT by default, everything works until first Thread.sleep(int) was called, then you have an issue with Concurency in Swing,

必须查看 Swing Timer,它提供了基本的在 Swing 中绘制 或延迟任何事件的 funkcionalities在 Swing GUI 中,

Have to look at Swing Timer, which providing basic funkcionalities for painting in the Swing or delaying any event(s) in the Swing GUI ,

如果您的更新不是关于图形,那么您可以通过将 Swing GUI 的输出包装到 invokeLater()

If your update(s) isn't about Graphics then you can invoke EDT by wrapping output to the Swing GUI to the invokeLater()

这篇关于EDT和其他线程关系关于repaint()方法java的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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