protected void paintComponent(Graphics g) [英] protected void paintComponent(Graphics g)

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

问题描述

我们可以覆盖 JComponent paintComponent(Graphics g)方法。

自动调用它来刷新屏幕。

It is called automatically to refresh the screen.

我可以做些什么,例如每100毫秒定期调用一次。

What can I do that is called regularly, for example every 100 ms.

这可能吗?

推荐答案

也许你的目的是刷新组件每ms ?

Maybe your purpose is refreshing the component every certain ms?

如果是这样,有几个选项可供使用<使用定时是第一个选项。例如此处

大多数人使用的选项是 Thread 动画。以下是一个示例

还有一个可供下载的时间框架。我无法找到一个可用的链接,但只是在互联网上搜索它。

If so, there's a few options available.
The use of Timer is a first option. Example here.
The option most people use is Thread animation. Here is an example.
Also there's a timing framework available to download. I can't find an available link, but just search for it on the internet.

希望这有助于。

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

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