📄 actionupdater.java
字号:
package twplanegame;import java.util.*;class ActionUpdater extends TimerTask{ // list of all the listeners private final ActionListener[] m_listener = new ActionListener[20]; private final Timer m_updateTimer = new Timer(); /** * Creates a ActionUpdater object and starts it. * * @param initSleep Initial sleep time. */ public ActionUpdater(int initSleep, int interval) { m_updateTimer.schedule(this, initSleep, interval); } /** * Registers the ActionListener that should be informed of an action to be * performed. * * @param listener The listener that should be informed of an action to be * performed. * @return true if it was registered; false otherwise */ public boolean register(ActionListener listener) { // find an empty spot, and save the reference for (int i = 0; i < m_listener.length; i++) { if (m_listener[i] == null) { m_listener[i] = listener; return true; } } return false; } /** * Perform the repetition of the key. */ public void run() { // ask each listener to perform an action for (int i = 0; i < m_listener.length; i++) { if (m_listener[i] != null) { m_listener[i].performAction(); } } }//void run()}//class ActionUpdater
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -