socketmidlet.java

来自「3G体验手机展示程序 3G体验手机展示程序 3G体验手机展示程序」· Java 代码 · 共 63 行

JAVA
63 行
字号
package com.hongguan.lifeshowclient2;

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

public class socketMIDlet extends MIDlet implements CommandListener { // 

	private static final String SERVER = "Server"; 
	private static final String CLIENT = "Client"; 
	private static final String[] names = {CLIENT}; 
	private static Display display; 
	private Form f; 
	private ChoiceGroup cg; 
	private boolean isPaused; 
	private Client client; 
	private Command exitCommand = new Command("Exit", Command.EXIT, 1); 
	private Command startCommand = new Command("Start", Command.ITEM, 1); 

	public socketMIDlet() { 
		display = Display.getDisplay(this); 
		f = new Form("Socket Demo"); 
		cg = new ChoiceGroup("Please select peer",Choice.EXCLUSIVE, names, null); 
		f.append(cg); 
		f.addCommand(exitCommand); 
		f.addCommand(startCommand); 
		f.setCommandListener(this); 
		display.setCurrent(f); 
	} 

	public boolean isPaused() { 
		return isPaused; 
	} 

	public void startApp() { 
		isPaused = false; 
	} 

	public void pauseApp() { 
		isPaused = true; 
	}

	public void destroyApp(boolean unconditional) { 
		if (client != null) { 
			client.stop(); 
		} 
	} 

	public void commandAction(Command c, Displayable s) { 
		if (c == exitCommand) { 
			destroyApp(true); 
			notifyDestroyed(); 
		} else if (c == startCommand) { 
			String name = cg.getString(cg.getSelectedIndex()); 
			if (name.equals(CLIENT)) { 
				client = new Client(this); 
				client.start(); 
			} 
		} 
	} 
}

⌨️ 快捷键说明

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