propertytest.java

来自「是一本J2ME的教材书」· Java 代码 · 共 58 行

JAVA
58
字号
//PropertyTest.java
import javax.microedition.midlet.*;
import javax.microedition.lcdui.*;
public class PropertyTest extends MIDlet implements CommandListener
{
	private Command exitCommand;
	private Display display;
	public PropertyTest()
	{
		display = Display.getDisplay(this);
		exitCommand = new Command("Exit", Command.SCREEN, 2);
	}
	public void startApp()
	{
		TextBox t = new TextBox("Properties", "", 256, 0);
		t.addCommand(exitCommand);
		t.setCommandListener(this);
		t.setString( getSomeProperties() );
		display.setCurrent(t);
	}
	public void pauseApp()
	{ }
	public void destroyApp(boolean unconditional)
	{ }
	public void commandAction(Command c, Displayable s)
	{
		if (c == exitCommand)
		{
			destroyApp(false);
			notifyDestroyed();
		}
	}
	public String getSomeProperties()
	{
		String [] names = {
			"MIDlet-Vendor",
			"MIDlet-Name",
			"MIDlet-Version",
			"MicroEdition-Profile",
			"MicroEdition-Configuration",
		};
		String s = "";
		for( int i=0; i<names.length; i++ ) 
			s += names[i] + " = \n  " + getAppProperty( names[i] )+"\n";
		
		names = new String[]{
			//"microedition.profile",
			//"microedition.configuration",
			//"microedition.platform",
			"microedition.locale",
			"microedition.encoding",
		};
		for( int i=0; i<names.length; i++ ) 
			s += names[i] + " = \n  " + System.getProperty( names[i] )+"\n";

		return s;
	}
}

⌨️ 快捷键说明

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