Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
JInput 中的按钮和 HAT 按下是基于事件的,这意味着如果我按下按钮 1,它只会在我按住它时触发一次,然后在我释放按钮时再次触发。我想这样做,如果我按住按钮,它仍然会继续调用我分配给它的方法。我该怎么做>
好的,所以我做了一些研究,最终得到了以下解决方案:
myTimer = new Timer(); myTimer.schedule(new TimerTask() { @Override public void run() { // Do stuff } }, 50, 50);
然后,当我需要停止计时器时,我会在另一种方法上调用以下内容。
myTimer.cancel; myTimer.purge;