J2ME Canvas
importjavax.microedition.midlet.MIDlet;importjavax.microedition.midlet.MIDletStateCha...
import javax.microedition.midlet.MIDlet;
import javax.microedition.midlet.MIDletStateChangeException;
import javax.microedition.lcdui.*;
public class Assignment extends MIDlet {
private Display display;
MyCanvas mc=new MyCanvas();
private int myCode;
private int m_KeyCode1;
public Assignment() {
}
protected void startApp() throws MIDletStateChangeException {
display=Display.getDisplay(this);
mc.setTitle("绘图");
display.setCurrent(mc);
}
protected void destroyApp(boolean arg0) throws MIDletStateChangeException {
}
protected void pauseApp() {
}
class MyCanvas extends Canvas{
public void paint(Graphics g){
g.setColor(255, 255, 255);
g.fillRect(0, 0, this.getHeight(), this.getWidth());
switch(myCode){
case 49: System.out.println("11111"); repaint(); //g.drawArc(60-10, 60-10, 2*10, 2*10, 0, 360);
}
}
public void keyPressed(int keyCode) {
myCode=keyCode;
}
protected void keyReleased(int keyCode)
{
m_KeyCode1=keyCode;
switch(m_KeyCode1){
}
}
}
}
为什么我运行程序之后按一会打印出来N个11111
怎么修改
哪位大哥教教我哈! 展开
import javax.microedition.midlet.MIDletStateChangeException;
import javax.microedition.lcdui.*;
public class Assignment extends MIDlet {
private Display display;
MyCanvas mc=new MyCanvas();
private int myCode;
private int m_KeyCode1;
public Assignment() {
}
protected void startApp() throws MIDletStateChangeException {
display=Display.getDisplay(this);
mc.setTitle("绘图");
display.setCurrent(mc);
}
protected void destroyApp(boolean arg0) throws MIDletStateChangeException {
}
protected void pauseApp() {
}
class MyCanvas extends Canvas{
public void paint(Graphics g){
g.setColor(255, 255, 255);
g.fillRect(0, 0, this.getHeight(), this.getWidth());
switch(myCode){
case 49: System.out.println("11111"); repaint(); //g.drawArc(60-10, 60-10, 2*10, 2*10, 0, 360);
}
}
public void keyPressed(int keyCode) {
myCode=keyCode;
}
protected void keyReleased(int keyCode)
{
m_KeyCode1=keyCode;
switch(m_KeyCode1){
}
}
}
}
为什么我运行程序之后按一会打印出来N个11111
怎么修改
哪位大哥教教我哈! 展开
1个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询