keyTestCanvas.java
上传用户:gyyuli
上传日期:2013-07-09
资源大小:3050k
文件大小:1k
源码类别:

J2ME

开发平台:

Java

  1. package keyTest;
  2. import javax.microedition.lcdui.*;
  3. import javax.microedition.midlet.*;
  4. import java.io.*;
  5. public class keyTestCanvas extends Canvas
  6. {
  7. public keyTestCanvas()
  8.         {
  9.     
  10.         }
  11.         public void paint(Graphics g)
  12.         {   int width=this.getWidth();
  13.             int height=this.getHeight();
  14.             g.setColor(0xFFFFFF);
  15.             g.fillRect(0,0,width,height);       
  16.         }
  17.         protected void keyPressed(int keyCode){
  18.         System.out.println("键盘"+getKeyName(keyCode)+"被按下,值为"+keyCode);
  19.         }
  20.         protected void keyReleased(int keyCode){
  21.         System.out.println("键盘"+getKeyName(keyCode)+"释放");
  22.         }
  23.         protected void keyRepeated(int keyCode){
  24.         System.out.println("键盘"+getKeyName(keyCode)+"被持续按下");
  25.         }
  26.      
  27. }