java Me中的按键和触屏接口的处理示例
package com.canvas;
import javax.microedition.lcdui.Canvas;
import javax.microedition.lcdui.Command;
import javax.microedition.lcdui.CommandListener;
import javax.microedition.lcdui.Display;
import javax.microedition.lcdui.Displayable;
import javax.microedition.lcdui.Graphics;
import javax.microedition.midlet.MIDlet;
import javax.microedition.midlet.MIDletStateChangeException;
public class KeyCanvas extends MIDlet
{
private keyPanel cns=null;
private Display display=null;
public KeyCanvas()
{
cns=new keyPanel(this);
display=Display.getDisplay(this);
}
protected void destroyApp(boolean arg0) throws MIDletStateChangeException {
}
protected void pauseApp() {
}
protected void startApp() throws MIDletStateChangeException {
display.setCurrent(cns);
}
public void close()
{
try
{
destroyApp(true);
}
catch (MIDletStateChangeException e)
{
e.printStackTrace();
}
notifyDestroyed();
}
}
class keyPanel extends Canvas implements CommandListener
{
String key="请按下一个键";
相关新闻>>
- 发表评论
-
- 最新评论 更多>>