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

📄 loginform.java

📁 StarShip Battle 2004 game The Developing Mobile Phone Applications With J2ME Technology course provi
💻 JAVA
字号:
import javax.microedition.lcdui.*;

public class LoginForm implements CommandListener
{
	private SecretWordItem swi;
	private Form loginForm;
	private TextField userEntry;
	
	private Display deviceDisplay;
	private MainMenu mainMenu;
	
	private Command enter;
	
	
	public LoginForm(Display d)
	{
		deviceDisplay = d;
		
		swi = new SecretWordItem();
		userEntry = new TextField("Password", null, 25, TextField.ANY);
		enter = new Command("Enter", Command.OK, 1);
		
		loginForm = new Form("Login");
		loginForm.append(swi);
		loginForm.append(userEntry);
		loginForm.addCommand(enter);
		loginForm.setCommandListener(this);
	}
	
	public void registerMenu(MainMenu menu)
	{
		mainMenu = menu;
	}
	
	public void showLoginForm()
	{
		deviceDisplay.setCurrent(loginForm);
	}

	public void showMenu()
	{
		mainMenu.showMenu();
	}
	
	public void commandAction(Command c, Displayable d)
	{
		if (swi.checkWord(userEntry.getString()))
		{
			showMenu();
		}
		else
		{
			Alert err = new Alert("Invalid Password!", "Invalid Password\n Please try again", null, AlertType.ERROR);
			err.setTimeout(Alert.FOREVER);
			deviceDisplay.setCurrent(err, loginForm);
		}
	}
}

⌨️ 快捷键说明

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