Redian新闻
>
how to update swing components
avatar
how to update swing components# Java - 爪哇娇娃
w*r
1
When a function is running, the frame seems dead. It won't be repainted even
if it is only moved. If modify some text in the component, it won't update it.
How to make it work? I want to show something when the algorithm is running. I
tried "validate", "update", "repaint". None of them works. Maybe I didn't call
them in the correct way. Nothing need to do when using awt components. The
component will be updated whenever it is modified. Anything special with
swing?
Thank you very much
avatar
f*h
2
remeber java vm does the swing related sutff in a separate thread, so if you
invoke method like update,repaint in your computational-expensive thread, you
will never see any update immediately.
Look at Timer class. It will help you.

【在 w********r 的大作中提到】
: When a function is running, the frame seems dead. It won't be repainted even
: if it is only moved. If modify some text in the component, it won't update it.
: How to make it work? I want to show something when the algorithm is running. I
: tried "validate", "update", "repaint". None of them works. Maybe I didn't call
: them in the correct way. Nothing need to do when using awt components. The
: component will be updated whenever it is modified. Anything special with
: swing?
: Thank you very much

相关阅读
logo
联系我们隐私协议©2024 redian.news
Redian新闻
Redian.news刊载任何文章,不代表同意其说法或描述,仅为提供更多信息,也不构成任何建议。文章信息的合法性及真实性由其作者负责,与Redian.news及其运营公司无关。欢迎投稿,如发现稿件侵权,或作者不愿在本网发表文章,请版权拥有者通知本网处理。