java Me中的按键和触屏接口的处理示例
来源:技术人生 责任编辑:栏目编辑 发表时间:2013-07-01 14:02 点击:次
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="请按下一个键";
private boolean key_event=true;
private boolean pointer_event=true;
private int startx=0;
private int starty=0;//开始坐标位置
private int currentx = 0;//当前指针坐标位置
private int currenty = 0;
private KeyCanvas keycanvas=null;
相关新闻>>
- 发表评论
-
- 最新评论 更多>>