?? irconnectiontest.java
字號:
/*
* IRConnectionTest.java
*
* Created on 2006年1月2日, 下午11:24
*/
import javax.microedition.io.CommConnection;
import javax.microedition.io.Connector;
import javax.microedition.midlet.*;
import javax.microedition.lcdui.*;
/**
*
* @author Liu Bin
* @version
*/
public class IRConnectionTest extends MIDlet implements CommandListener{
private Form form = new Form("紅外連接");
public void startApp() {
form.setCommandListener(this);
form.addCommand(new Command("連接", Command.SCREEN, 1)) ;
form.addCommand(new Command("退出", Command.EXIT, 1)) ;
Display.getDisplay(this).setCurrent(form);
}
public void pauseApp() {
}
public void destroyApp(boolean unconditional) {
}
public void commandAction(Command command,
Displayable displayable) {
if (command.getLabel().equals("退出")) {
destroyApp(true);
notifyDestroyed();
} else if (command.getLabel().equals("連接")) {
CommConnection cc;
try {
String conStr = "comm:IR1;baudrate=9600";
cc = (CommConnection)Connector.open(conStr);
form.append("打開紅外端口IR1\n");
int baudrate = cc.getBaudRate();
form.append("連接速率:"+ baudrate + "\n");
cc.close();
}catch (Exception e) {
form.append("打開紅外端口錯誤: " + e.toString());
System.out.println("打開紅外端口錯誤: " + e.toString());
}
}
}
}
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -