看板java
標 題Re: [問題] 請問KeyEvent中如何設定時間
發信站未來最舊小棧 (Wed Jun 14 03:27:09 2006)
轉信站ptt!ctu-reader!ctu-peer!news.nctu!netnews.csie.nctu!news.ee.ttu!news.n
※ 引述《Gentoo (賤兔..><")》之銘言:
: ※ 引述《[email protected] (ˋ_ˊ)》之銘言:
: : 想要問的就是
: : 用keyPressed(KeyEvent e)來抓鍵盤的按鍵
: : 按第一下時不放開一直按著
: : 第一下結束到之後抓到同一個按鍵會有停頓
: : 要如何設定鍵盤讀取按鍵的間隔時間
: : 還是說有其他的解決方法
: : 希望各位高手可以提供方法~~
: : 謝謝!!
: http://java.sun.com/j2se/1.5.0/docs/api/java/awt/event/InputEvent.html
: #getWhen()
: 聽不懂你要做啥?
: long t, threshold;
: void keyPressed(KeyEvent e)
: {
: if( t-e.getWhen()>=threshold )
e.getWhen()-t 才對...Orz
: {
: // do something
: t = e.getWhen();
: }
: }
...
--
◢█◣▏◤█◣ ◆未來最舊小棧 Oldest Future Object
█●▇█▁˙█ ◆通訊頻率 OfO.twbbs.org
◥█◢▉◥█◤ ◆來源座標
sparc13.cc.ncu.edu.tw