Bootstrap

java用户界面实验总结_J2ME实验报告(高级用户界面).doc

实验报告

姓名: 专业: 学号:

一 题目:高层用户界面设计

二 设备:

计算机名称:

配置:

三 软件环境: JDK(jdk-6u11-windows-i586-p), WTK(sun_java_wireless_toolkit-2_5_2-ml-windows), Eclipse(eclipse-java-ganymede-SR1-win32),

EclipseME(eclipseme.feature_1.7.9_site) ,操作系统:

WINDOWS 7旗舰版。

四 程序流程图:

五 程序代码:

import javax.microedition.midlet.*;

import javax.microedition.lcdui.*;

public class UserLogin extends MIDlet implements CommandListener {

private Display display;

private Command exitCommand;

private Command loginCommand;

private TextField textfield1;

private TextField textfield2;

private TextBox textBox;

private Alert alert;

private Alert alert2;

private Form myform;

public UserLogin() {

display = Display.getDisplay(this);

loginCommand = new Command("登陆",Command.SCREEN,1);

exitCommand = new Command("退出",Command.SCREEN,1);

myform = new Form("用户登录");

textfield1 = new TextField("用户名:","",20,TextField.ANY);

textfield2=new TextField("密 码","",20,TextField.PASSWORD);

textBox = new TextBox("欢迎您","",200,TextField.ANY);

myform.addCommand(loginCommand);

myform.addCommand(exitCommand);

myform.append(textfield1);

myform.append(textfield2);

myform.setCommandListener(this);

alert = new Alert("用户窗口","登陆成功!",null,AlertType.INFO);

alert2 = new Alert("警告","输入用户或密码有误,请重新输入!",null,AlertType.INFO);

alert.setTimeout(Alert.FOREVER);

}

public void startApp() {

display.setCurrent(myform);

}

public void pauseApp() {

}

public void destroyApp(boolean uncondition) {

}

public void commandAction(Command c, Displayable d) {

if(c == loginCommand)

{

if(textfield1.getString().equals("lien")&&textfield2.getString().equals("lien"))

{

display.setCurrent(alert,display.getCurrent());

textBox.setString("用户名:"+textfield1.getString()+" "+"密码:"+textfield2.getString());

;