📄 loginform.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 + -