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

📄 j2me_examples.java

📁 developing wireless connection in j2me
💻 JAVA
字号:

import javax.microedition.lcdui.*;
import javax.microedition.midlet.*;

public class J2ME_examples extends MIDlet implements CommandListener{
	
	private Display display;
	private Screen[] screens;
	private Command exitCommand;
	private Command backCommand;
	private List exampleslist;
	private String[] examples = {"Strings","Alerts","TextFields","Gauges"}; 
	 

	 
	public void startApp (){
		createCommands();
		createScreens();
		createLists();
		
		display = Display.getDisplay(this);
		display.setCurrent(exampleslist);
	}
            	
	public void destroyApp(boolean b) { }
   
	public void pauseApp() { }
	
	public void createCommands(){
		exitCommand = new Command("Exit", Command.EXIT, 0);
		backCommand = new Command("Back", Command.BACK, 0);
	}
		
	public void createScreens() {
		screens = new Screen[examples.length];
		screens[0] = stringExample();
		screens[1] = null;
		screens[2] = null;
		screens[3] = null; 
	}
	
	public void createLists() {
		exampleslist = new List("Select Example", List.IMPLICIT);
		for (int i =0; i<examples.length; i++) {
			exampleslist.append(examples[i], null);
		}
		exampleslist.setCommandListener(this);
	}


	public Form stringExample() {
		Form form = new Form("String Item");
		form.append(new StringItem(null,"Hello"));
		form.append(new StringItem("Bye",null));
		form.append(new StringItem("Label","Text\n"));
		form.append(new StringItem("Yo", "Man\n"));
		addCommands(form);
		return form;
	}
	
	 public void commandAction(Command c, Displayable d) {
	 	if(d == exampleslist) {
			int index = exampleslist.getSelectedIndex();
			display.setCurrent(screens[index]);
		}
		else if(c == exitCommand)
			notifyDestroyed();
		else if(c == backCommand)
			display.setCurrent(exampleslist);
	 }
	 
	 private void addCommands(Displayable d) {
        d.addCommand(exitCommand);
        d.addCommand(backCommand);
        d.setCommandListener(this);
	}
}

⌨️ 快捷键说明

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