?? echoclientmidlet.java
字號(hào):
// EchoClientMIDlet.java// Andrew Davison, ad@fivedots.coe.psu.ac.th, August 2005/* This screen starts the device and services search, and reports its ongoing status. At the end of the search, a services list screen (ServicesList) is displayed. A service is chosen from the list, and a form allows the user to send messages and receive echoed responses from the server. The echoed messages are changed to uppercase.*/import javax.microedition.midlet.*;import javax.microedition.lcdui.*;import java.util.*;public class EchoClientMIDlet extends MIDlet implements CommandListener { // UUID and name of the echo service private static final String UUID_STRING = "11111111111111111111111111111111"; // 32 hex digit string (will become 128 bit ID) private static final String SERVICE_NAME = "echoserver"; // use lowercase // GUI elements private Form form; private Gauge searchGauge; private int gaugeIndex; private StringItem statusSI; private Command exitCmd; private Display display; private ServiceFinder serviceFinder; public EchoClientMIDlet() { // build GUI form = new Form("Searching"); exitCmd = new Command("Exit", Command.EXIT, 1); form.addCommand(exitCmd); statusSI = new StringItem("Status: ", "Starting..."); searchGauge = new Gauge("Bluetooth Service Search", false, Gauge.INDEFINITE, Gauge.CONTINUOUS_RUNNING); form.append(statusSI); gaugeIndex = form.append(searchGauge); form.setCommandListener(this); // start searching for services serviceFinder = new ServiceFinder(this, UUID_STRING, SERVICE_NAME); } // end of EchoClientMIDlet() protected void startApp() { display = Display.getDisplay(this); display.setCurrent(form); } // end of startApp() protected void pauseApp() {} protected void destroyApp(boolean unconditional) // callable from here, ServicesList, and ClientForm { notifyDestroyed(); } public void commandAction(Command c, Displayable d) { if (c == exitCmd) destroyApp(true); } // end of commandAction() // ----------------- reporting from ServiceFinder -------------- public void setStatus(String msg) { statusSI.setText(msg); } public void searchError(String msg) // show error message and remove gauge { statusSI.setText(msg); searchGauge.setValue(Gauge.CONTINUOUS_IDLE); form.delete(gaugeIndex); } // end of searchError() public void showServices(Hashtable searchTable) // show the services list screen, so the user can choose a service { ServicesList sl = new ServicesList(searchTable, this, display); display.setCurrent(sl); }} // end fo EchoClientMIDlet class
?? 快捷鍵說(shuō)明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號(hào)
Ctrl + =
減小字號(hào)
Ctrl + -