Redian新闻
>
怎么在application实现delay?
avatar
怎么在application实现delay?# Java - 爪哇娇娃
g*g
1
比如我需要交换两个icon,停一秒钟,再
交换回来。
试了Thread.currentThread().wait(1000);
不会改变GUI.
avatar
n*k
2

A Timer??? You'd better elaborate your question a little.

【在 g*****g 的大作中提到】
: 比如我需要交换两个icon,停一秒钟,再
: 交换回来。
: 试了Thread.currentThread().wait(1000);
: 不会改变GUI.

avatar
g*g
3
Let's say I am writing a small game. With a lot of
buttons in it.
In the game, when the user click two adjacent buttons,
if they exchange and if some criteria meets, I'll change
something. If not, the layout get back to original.
Now how to have the temporary state displayed for one
second? The temporary state refers to after they exchange..

【在 n*****k 的大作中提到】
:
: A Timer??? You'd better elaborate your question a little.

avatar
KG
4
Although the scenario is still not clear, I would guess that you put
Thread.currentThread.wait(1000) inside an event dispatch thread. That would
just put your event dispatch thread on hold for a sec, during which time
period UI won't be updated. Using a Timer might work...

【在 g*****g 的大作中提到】
: Let's say I am writing a small game. With a lot of
: buttons in it.
: In the game, when the user click two adjacent buttons,
: if they exchange and if some criteria meets, I'll change
: something. If not, the layout get back to original.
: Now how to have the temporary state displayed for one
: second? The temporary state refers to after they exchange..

avatar
g*g
5
That's the scenario, can you give some details on
how to update UI when the working thread is suspended?

【在 KG 的大作中提到】
: Although the scenario is still not clear, I would guess that you put
: Thread.currentThread.wait(1000) inside an event dispatch thread. That would
: just put your event dispatch thread on hold for a sec, during which time
: period UI won't be updated. Using a Timer might work...

avatar
m*t
6

I think his point is *not* to suspend any thread. Instead,
use a timer to triger the second update.

【在 g*****g 的大作中提到】
: That's the scenario, can you give some details on
: how to update UI when the working thread is suspended?

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