⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 pwdform.java

📁 一个j2me很简单的用户名密码注册的登陆框源代码
💻 JAVA
字号:
import java.io.IOException;
import java.util.Enumeration;

import javax.microedition.lcdui.Alert;
import javax.microedition.lcdui.AlertType;
import javax.microedition.lcdui.Choice;
import javax.microedition.lcdui.Command;
import javax.microedition.lcdui.CommandListener;
import javax.microedition.lcdui.Displayable;
import javax.microedition.lcdui.Form;
import javax.microedition.lcdui.Image;
import javax.microedition.lcdui.TextField;

//修改密码界面
public class PWDForm extends Form implements CommandListener
{
	private Command cancel;
	private Command ok;
	
	private TextField pwd_old;
	private TextField pwd_new;
	private TextField pwd_con;
	
	private User user;
	
	public PWDForm(String title, User user)
	{
		super(title);
		
		this.user = user;
		
		cancel = new Command("取消", Command.CANCEL, 1);
		ok = new Command("确定", Command.OK, 1);
		
		pwd_old = new TextField("旧密码:", null, 20, TextField.PASSWORD);
		pwd_new = new TextField("新密码:", null, 20, TextField.PASSWORD);
		pwd_con = new TextField("确认新密码:", null, 20, TextField.PASSWORD);
		
		this.append(pwd_old);
		this.append(pwd_new);
		this.append(pwd_con);
		this.addCommand(cancel);
		this.addCommand(ok);
		this.setCommandListener(this);
	}

	public void commandAction(Command c, Displayable d)
	{
		if (c.equals(cancel))
		{
			MyLoginMIDlet.midlet.showWelcomeList(this.user);
		}
		else if (c.equals(ok))
		{	
			String pOld = pwd_old.getString();
			String pNew = pwd_new.getString();
			String pCon = pwd_con.getString();
			
			if (!pOld.equals(user.getPWD()))
			{
				Alert al = new Alert("错误", "旧密码错误!", null, AlertType.ERROR);
				al.setTimeout(2000);
				MyLoginMIDlet.midlet.showAlert(al, this);
				return;
			}
			
			if (!pNew.equals(pCon))
			{
				Alert al = new Alert("错误", "确认新密码错误!", null, AlertType.ERROR);
				al.setTimeout(2000);
				MyLoginMIDlet.midlet.showAlert(al, this);
				return;
			}
			
			int index = MyLoginMIDlet.userList.indexOf(this.user);
			this.user.setPWD(pNew);
			MyLoginMIDlet.userList.setElementAt(this.user, index);
			
			Alert al = new Alert("密码修改", this.user.getUserName()+"密码修改成功!", null, AlertType.INFO);
			al.setTimeout(2000);
			WelcomeList list = new WelcomeList(user.getUserName()+",欢迎光临!",Choice.IMPLICIT, user);
			MyLoginMIDlet.midlet.showAlert(al, list);
		}
	}

}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -