我有一个手机,她的名字叫:NOKIA 5300,我爱她,所以我觉得使用Java让她的思想更加丰富!
在屏幕上查找英文词汇
[
2010/01/05 08:42 | by fubin ]
2010/01/05 08:42 | by fubin ]
J2ME下实现XML解析
[
2009/08/07 23:49 | by fubin ]
2009/08/07 23:49 | by fubin ]
一个简单的J2me登陆窗口
[
2008/09/26 13:25 | by fubin ]
2008/09/26 13:25 | by fubin ]
/*
* A free J2ME sample program to demonstrate
* a SIMPLE LOGIN SCREEN TO LOGIN TO A HTTP SERVER
* FROM A J2ME phone
*
* @author William Alexander
* free for use as long as this comment is included in
* in the program as it is
* More Free Java programs available for download
* at http://www.java-samples.com
*
*/
import javax.microedition.lcdui.*;
import javax.microedition.midlet.*;
import java.io.*;
import java.lang.*;
import javax.microedition.io.*;
import javax.microedition.rms.*;
public class Login extends MIDlet implements CommandListener {
TextField UserName=null;
TextField Location=null;
Form authForm,mainscreen;
TextBox t = null;
StringBuffer b = new StringBuffer();
private Display myDisplay = null;
private Command okCommand = new Command("OK", Command.OK, 1);
private Command exitCommand = new Command("Exit", Command.EXIT, 2);
private Command backCommand = new Command("Back", Command.BACK, 2);
private Alert alert = null;
public Login() {
myDisplay = Display.getDisplay(this);
UserName=new TextField("Your Name","",10,TextField.ANY);
Location=new TextField("Location","",10,TextField.ANY);
authForm=new Form("Identification");
mainscreen=new Form("Logging IN");
mainscreen.append("Logging in....");
mainscreen.addCommand(backCommand);
authForm.append(UserName);
authForm.append(Location);
authForm.addCommand(okCommand);
authForm.addCommand(exitCommand);
authForm.setCommandListener(this);
myDisplay.setCurrent(authForm);
}
public void startApp() throws MIDletStateChangeException {
}
public void pauseApp() {
}
protected void destroyApp(boolean unconditional)
throws MIDletStateChangeException {
}
public void commandAction(Command c, Displayable d) {
if ((c == okCommand) && (d == authForm)) {
if (UserName.getString().equals("") || Location.getString().equals("")){
alert = new Alert("Error", "You should enter Username and Location", null, AlertType.ERROR);
alert.setTimeout(Alert.FOREVER);
myDisplay.setCurrent(alert);
}
else{
//myDisplay.setCurrent(mainscreen);
login(UserName.getString(),Location.getString());
}
}
if ((c == backCommand) && (d == mainscreen)) {
myDisplay.setCurrent(authForm);
}
if ((c == exitCommand) && (d == authForm)) {
notifyDestroyed();
}
}
public void login(String UserName,String PassWord) {
HttpConnection connection=null;
DataInputStream in=null;
String url="http://www.cujava.com/";
OutputStream out=null;
try
{
connection=(HttpConnection)Connector.open(url);
connection.setRequestMethod(HttpConnection.POST);
connection.setRequestProperty("IF-Modified-Since", "2 Oct 2002 15:10:15 GMT");
connection.setRequestProperty("User-Agent","Profile/MIDP-1.0 Configuration/CLDC-1.0");
connection.setRequestProperty("Content-Language", "en-CA");
connection.setRequestProperty("Content-Length",""+ (UserName.length()+PassWord.length()));
connection.setRequestProperty("UserName",UserName);
connection.setRequestProperty("PassWord",PassWord);
out = connection.openDataOutputStream();
out.flush();
in = connection.openDataInputStream();
int ch;
while((ch = in.read()) != -1) {
b.append((char) ch);
//System.out.println((char)ch);
}
//t = new TextBox("Reply",b.toString(),1024,0);
mainscreen.append(b.toString());
if(in!=null)
in.close();
if(out!=null)
out.close();
if(connection!=null)
connection.close();
}
catch(IOException x){}
myDisplay.setCurrent(mainscreen);
}
}
* A free J2ME sample program to demonstrate
* a SIMPLE LOGIN SCREEN TO LOGIN TO A HTTP SERVER
* FROM A J2ME phone
*
* @author William Alexander
* free for use as long as this comment is included in
* in the program as it is
* More Free Java programs available for download
* at http://www.java-samples.com
*
*/
import javax.microedition.lcdui.*;
import javax.microedition.midlet.*;
import java.io.*;
import java.lang.*;
import javax.microedition.io.*;
import javax.microedition.rms.*;
public class Login extends MIDlet implements CommandListener {
TextField UserName=null;
TextField Location=null;
Form authForm,mainscreen;
TextBox t = null;
StringBuffer b = new StringBuffer();
private Display myDisplay = null;
private Command okCommand = new Command("OK", Command.OK, 1);
private Command exitCommand = new Command("Exit", Command.EXIT, 2);
private Command backCommand = new Command("Back", Command.BACK, 2);
private Alert alert = null;
public Login() {
myDisplay = Display.getDisplay(this);
UserName=new TextField("Your Name","",10,TextField.ANY);
Location=new TextField("Location","",10,TextField.ANY);
authForm=new Form("Identification");
mainscreen=new Form("Logging IN");
mainscreen.append("Logging in....");
mainscreen.addCommand(backCommand);
authForm.append(UserName);
authForm.append(Location);
authForm.addCommand(okCommand);
authForm.addCommand(exitCommand);
authForm.setCommandListener(this);
myDisplay.setCurrent(authForm);
}
public void startApp() throws MIDletStateChangeException {
}
public void pauseApp() {
}
protected void destroyApp(boolean unconditional)
throws MIDletStateChangeException {
}
public void commandAction(Command c, Displayable d) {
if ((c == okCommand) && (d == authForm)) {
if (UserName.getString().equals("") || Location.getString().equals("")){
alert = new Alert("Error", "You should enter Username and Location", null, AlertType.ERROR);
alert.setTimeout(Alert.FOREVER);
myDisplay.setCurrent(alert);
}
else{
//myDisplay.setCurrent(mainscreen);
login(UserName.getString(),Location.getString());
}
}
if ((c == backCommand) && (d == mainscreen)) {
myDisplay.setCurrent(authForm);
}
if ((c == exitCommand) && (d == authForm)) {
notifyDestroyed();
}
}
public void login(String UserName,String PassWord) {
HttpConnection connection=null;
DataInputStream in=null;
String url="http://www.cujava.com/";
OutputStream out=null;
try
{
connection=(HttpConnection)Connector.open(url);
connection.setRequestMethod(HttpConnection.POST);
connection.setRequestProperty("IF-Modified-Since", "2 Oct 2002 15:10:15 GMT");
connection.setRequestProperty("User-Agent","Profile/MIDP-1.0 Configuration/CLDC-1.0");
connection.setRequestProperty("Content-Language", "en-CA");
connection.setRequestProperty("Content-Length",""+ (UserName.length()+PassWord.length()));
connection.setRequestProperty("UserName",UserName);
connection.setRequestProperty("PassWord",PassWord);
out = connection.openDataOutputStream();
out.flush();
in = connection.openDataInputStream();
int ch;
while((ch = in.read()) != -1) {
b.append((char) ch);
//System.out.println((char)ch);
}
//t = new TextBox("Reply",b.toString(),1024,0);
mainscreen.append(b.toString());
if(in!=null)
in.close();
if(out!=null)
out.close();
if(connection!=null)
connection.close();
}
catch(IOException x){}
myDisplay.setCurrent(mainscreen);
}
}
J2ME基础练习代码
[
2008/06/16 10:28 | by fubin ]
2008/06/16 10:28 | by fubin ]
我可爱的Nokia5300丢了
[
2007/08/20 15:12 | by fubin ]
2007/08/20 15:12 | by fubin ]
案件描述:今天中午,我最喜欢的一款手机:5300离我而去了,就在我从汽车后坐换到前坐的一杀那!我现在心情很差。
我喜欢5300是因为我在它上面开发了我第一个java手机游戏和软件。我太伤心了。
我喜欢5300是因为我在它上面开发了我第一个java手机游戏和软件。我太伤心了。
J2me游戏控制基础(测试环境:Nokia 5300 Series 40)
[
2007/06/10 23:21 | by fubin ]
2007/06/10 23:21 | by fubin ]



下载文件


