📄 sendform.java.svn-base
字号:
import javax.microedition.lcdui.*;
import javax.microedition.io.*;
import javax.microedition.midlet.*;
import java.io.*;
import java.util.*;
/**
* Allow a user to enter a single text input field
*
*/
public class SendForm extends javax.microedition.lcdui.Form
implements CommandListener,DataListener {
/**
*
*/
Testlet app;
private Command done = new Command("发送", Command.OK, 1);
private Command exit = new Command("返回",Command.CANCEL,2 );
TextField textField;
TextField tf;
ChoiceGroup chgrp;
HttpThread m_thread;
/**
* This constructor creates new BaseDemo with the given title & creates
* the standard commands for the demos.
*/
public SendForm (String title, Testlet app) {
super(title);
this.app = app;
addCommand(done);
addCommand(exit);
setCommandListener(this) ;
//setItemStateListener(new StateChangeListener (done, this));
textField = new TextField("发送地址", "http://61.153.21.82:8888/device/servlet/NewPhone?cmd=deviceinfo", 100, TextField.ANY );
tf = new TextField( "手机型号","",30,TextField.ANY );
tf.setString( System.getProperty( "platform" ) );
chgrp = new ChoiceGroup("连接方式", Choice.EXCLUSIVE);
chgrp.append("cmwap", null);
chgrp.append("cmnet", null);
this.append(tf );
append( chgrp );
this.append(textField);
}
/**
* Indicates that a command event has occurred.
*/
public void commandAction(Command c, Displayable d) {
if ( c == exit )
{
app.returnMainList();
}
else
{
m_thread = new HttpThread( chgrp.getSelectedIndex() == 0 );
m_thread.setDataListener( this );
m_thread.startThread();
String url = textField.getString() + "&name=" + tf.getString();
if ( chgrp.getSelectedIndex() == 0 )
m_thread.httpPost( "cmcc",url,DeviceInfos.getInstance().toXML() );
m_thread.httpPost( "data",url,DeviceInfos.getInstance().toXML() );
}
}
public void doInfo(String cmd ,byte[] bufInfo )
{
System.out.println( "received data:" + cmd );
if ( cmd.equals("data" ) )
{
Alert alert = new Alert( "发送成功","数据已经被传送到服务器,感谢使用Easymove 提供的服务",null,AlertType.INFO );
app.display.setCurrent( alert );
//app.returnMainList();
m_thread.stopThread();
}
}
public void doError(String cmd, String errorInfo)
{
Alert alert = new Alert( "发送错误",errorInfo,null,AlertType.INFO );
app.display.setCurrent( alert );
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -