keyrepeat.java

来自「英语背单词联网版本」· Java 代码 · 共 65 行

JAVA
65
字号
/* * KeyRepeat.java * * Created on 2003年4月29日, 下午9:40 */package handenglish; import javax.microedition.midlet.*;/** * * @author  sanmulong * @version */public class KeyRepeat extends Thread{    private boolean m_cancel = false;    private long m_sleepTime =100;    private int m_gameAction = 0;    private final KeyRepeator m_ui;    public KeyRepeat( KeyRepeator ui )    {        m_ui = ui;    }        public void cancel()    {        m_cancel = true;    }    public int getGameAction()    {        return m_gameAction;    }        public void setSleepPeriod( long sleepTime )    {        m_sleepTime = sleepTime;    }        public void startRepeat( int gameAction )    {        m_gameAction = gameAction;    }        public void stopRepeat( int gameAction )    {        if ( gameAction == m_gameAction )            m_gameAction = 0;    }        public void run()    {        while ( !m_cancel )        {            while ( m_gameAction == 0 && !m_cancel )                Thread.yield();            m_ui.movePressed( m_gameAction );            try            { sleep( m_sleepTime );            }            catch( Exception e ){}        }    }}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?