⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 getkeycodecanvas.java

📁 自己编写的测试手机属性
💻 JAVA
字号:
package zxhwolfe;

import javax.microedition.lcdui.Canvas;
import javax.microedition.lcdui.Graphics;
import javax.microedition.lcdui.Font;

public class GetKeycodeCanvas extends Canvas
{
	int keyCode;

	int gameAction;

	String keyName;

	boolean isDoubleBuffered = isDoubleBuffered();

	static int state;
	static int use;

	public GetKeycodeCanvas(GetKeycode getkyecode)
	{

	}

	public synchronized void keyPressed(int i)
	{
		keyCode = i;
		gameAction = getGameAction(i);
		keyName = getKeyName(i);
		System.out.println(keyCode);
		System.out.println(gameAction);
		System.out.println(keyName);
		System.out.println(isDoubleBuffered);

		if (i==56||i==53||i==50||i==48){
			
			
			if (i == 48 && state != 4)
			{
				state = 4;
			} else if (i == 48 && state == 4)
			{
				use= 2;//jinrujsr
				state= 0;
			} 

		if (i == 56 && state != 2)
		{
			state = 2;
		} else if (i == 56 && state == 2)
		{
			GetKeycode.quitApp();
		} 
		
		if (i == 53 && state != 3)
		{
			state = 3;
		} else if (i == 53 && state == 3)
		{
			use= 1;//jinrujiance
			state= 0;
		} 
		if (i == 50 && state != 5)
		{
			state = 5;
		} else if (i == 50 && state == 5)
		{
			use= 0;//fanhui anjianceshi
			state= 0;
		} }
		else{
			state=0;
		}
		repaint();
	}

	protected void paint(Graphics g)
	{
		g.setFont(Font.getFont(0,0,Font.SIZE_SMALL));
		g.setColor(0x00FFFFFF);
		g.fillRect(0, 0, getWidth(), getHeight());
		
		g.setColor(0x00000000);
		switch(use){
			
			case 0:
			
		
		g.drawString("现在进行的是按键测试:", 3, 0, 0);
		g.drawString("You pressed:", 3, 15, 0);
		g.drawString("Code:" + keyCode, 3, 30, 0);
		g.drawString("Action:" + gameAction, 3, 45, 0);
		g.drawString("Name:" + keyName, 3, 60, 0);
		
		
		g.drawString("连续按55键进入手机属性", 3, 80, 0);
		g.drawString("连续按22键返回按键测试", 3, 95, 0);
		g.drawString("连续按00键进入手机JSR", 3, 110, 0);
		g.drawString("连续按" + "\"88\"键" + "退出.", 3, 125, 0);
		break;
		
			case 1:
				
		
		String s = System.getProperty("microedition.configuration");
		g.drawString(getValue("硬件平台:", s ), 3, 0, 0);
		s = System.getProperty("microedition.platform");
		g.drawString(getValue("软件平台:", s ), 3, 15, 0);
		s = System.getProperty("microedition.encoding");
		g.drawString(getValue("系统编码:", s ), 3, 30, 0);
		s = System.getProperty("microedition.locale");
		g.drawString(getValue("区域设置:", s ), 3, 45, 0);
		s = System.getProperty("microedition.profiles");
		g.drawString(getValue("MIDP(JSR37or118):", s ), 3, 60, 0);
		 g.drawString(isDoubleBuffered==true?"支持双缓冲":"不支持双缓冲", 3, 75, 0);
		 String sSupported = System.getProperty("supports.mixing");
			if(sSupported == null)
			{
				sSupported = "不支持";
			}
			g.drawString("支持混音:" + sSupported,3,90,0);
			g.drawString("连续按22键返回按键测试", 3, 110, 0);
			g.drawString("连续按00键进入手机JSR", 3, 125, 0);
//			g.drawString("连续按" + "\"88\"键" + "退出.", 3, 125, 0);
		 break;
		 
			case 2:
		 
		s = System.getProperty("microedition.jtwi.version");
		g.drawString(getValue("JTWI(JSR185):", s ), 3, 0, 0);
		s = System.getProperty("microedition.media.version");
		g.drawString(getValue("MMA(JSR135):",s ), 3, 15, 0);
		
		s = System.getProperty("wireless.messaging.sms.smsc");
        if(s != null)
        {
        	g.drawString("WMA支持:"+"SMS:"+ s , 3, 30, 0);
           
            s = System.getProperty("wireless.messaging.mms.mmsc");
            g.drawString("MMS:"+ s , 3, 45, 0);
           
        } else
        {
        	g.drawString("WMA不支持!" ,3, 30, 0);
        }
        s = System.getProperty("bluetooth.api.version");
        g.drawString(getValue("BlueTooth(JSR82):", s) , 3, 60, 0);
        s = System.getProperty("microedition.pim.version");
        g.drawString(getValue("PIM(JSR75):", s ), 3, 75, 0);
        s = System.getProperty("microedition.io.file.FileConnection.version");
        g.drawString(getValue("FileConnection:",s ), 3, 90, 0);
        s = System.getProperty("microedition.sip.version");
        g.drawString(getValue("SIP(JSR180):", s ), 3, 105, 0);
        s = System.getProperty("microedition.m3g.version");
        g.drawString(getValue("M3G(JSR184):", s) , 3, 120, 0);
       
        break;
	}
	}
	private String getValue(String prompt, String s)
    {
        return prompt + ":" + (s != null ? s : "不支持") ;
    }

}

⌨️ 快捷键说明

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