TextFieldInputConstraintsDemo.java
上传用户:gyyuli
上传日期:2013-07-09
资源大小:3050k
文件大小:1k
源码类别:

J2ME

开发平台:

Java

  1. import javax.microedition.midlet.MIDlet;
  2. import javax.microedition.lcdui.*;
  3. public class TextFieldInputConstraintsDemo extends MIDlet implements CommandListener {
  4.     private Command exitCommand = new Command("Exit", Command.EXIT, 1);
  5.     private Form mainForm;
  6.     public TextFieldInputConstraintsDemo() {
  7.         mainForm = new Form("TextField演示");
  8.     }
  9.     protected void startApp() {
  10.             mainForm.append(
  11.             new TextField("文本", "", 30, TextField.ANY));
  12.             mainForm.append(
  13.     new TextField("邮箱", "", 30, TextField.EMAILADDR));
  14.             mainForm.append(
  15.                     new TextField("数字", "", 30, TextField.NUMERIC));
  16.             mainForm.append(
  17.                     new TextField("小数", "", 30, TextField.DECIMAL));
  18.             mainForm.append(
  19.                     new TextField("电话", "", 30, TextField.PHONENUMBER));
  20.             mainForm.append(
  21.                     new TextField("链接", "", 30, TextField.URL));
  22.             mainForm.append(
  23.                     new TextField("密码", "", 30, TextField.PASSWORD));
  24.             mainForm.addCommand(exitCommand);
  25.             mainForm.setCommandListener(this);
  26.             Display.getDisplay(this).setCurrent(mainForm);
  27.     }
  28.     public void commandAction(Command c, Displayable s) {
  29. if (c == exitCommand) {
  30.     destroyApp(false);
  31.     notifyDestroyed();
  32. }
  33.     }
  34.     protected void destroyApp(boolean unconditional) {
  35.     }
  36.     protected void pauseApp() {
  37.     }
  38. }