Redian新闻
>
一个关于事件的问题
avatar
一个关于事件的问题# Java - 爪哇娇娃
u*r
1
小弟偶在用java做一个电梯的例子。实际的电梯门打开的时候是由硬件产生一个事件,产
生相应动作,偶这个程序要模拟一下这个事件,所以我想用一个变量,每隔100毫秒减1来
表示门关的过程,当变量减到0的时候,产生一个门已经关的事件。程序的其它部分liste
n到这个事件,产生动作。想问一下这个事件在JAVA理如何产生?好象和mouseClicked等
事件还是不太一样。
avatar
g*g
2
check Timer.

【在 u******r 的大作中提到】
: 小弟偶在用java做一个电梯的例子。实际的电梯门打开的时候是由硬件产生一个事件,产
: 生相应动作,偶这个程序要模拟一下这个事件,所以我想用一个变量,每隔100毫秒减1来
: 表示门关的过程,当变量减到0的时候,产生一个门已经关的事件。程序的其它部分liste
: n到这个事件,产生动作。想问一下这个事件在JAVA理如何产生?好象和mouseClicked等
: 事件还是不太一样。

avatar
m*t
3

Do you need to do something like showing an animation during door closing?
Otherwise why would you need to be concerned with this "every 100ms"
business?

【在 u******r 的大作中提到】
: 小弟偶在用java做一个电梯的例子。实际的电梯门打开的时候是由硬件产生一个事件,产
: 生相应动作,偶这个程序要模拟一下这个事件,所以我想用一个变量,每隔100毫秒减1来
: 表示门关的过程,当变量减到0的时候,产生一个门已经关的事件。程序的其它部分liste
: n到这个事件,产生动作。想问一下这个事件在JAVA理如何产生?好象和mouseClicked等
: 事件还是不太一样。

avatar
u*r
4
Yes, I want to show the the procedure of door closing and opening. In the
coding work, I want to write a DoorListener (with Door and DoorEvent).
This is only for simulation so I should generate the event in the function of
class Door.
My main work is not simulate the elevator, I want to do more formal analysis
on my design in UML. I think the hardware generates the event in the real
system so maybe I can ignore how to generate the event in the design.
Anybody know that if a hardware manufactors

【在 m******t 的大作中提到】
:
: Do you need to do something like showing an animation during door closing?
: Otherwise why would you need to be concerned with this "every 100ms"
: business?

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