TextField pada J2ME
package aplikasi;
import javax.microedition.lcdui.Command;
import javax.microedition.lcdui.CommandListener;
import javax.microedition.lcdui.Display;
import javax.microedition.lcdui.Displayable;
import javax.microedition.lcdui.Form;
import javax.microedition.lcdui.TextField;
import javax.microedition.midlet.*;
/**
* @author Saniya
*/
public class LoginForm extends MIDlet implements CommandListener{
private Form form;
private TextField txtUserName,txtPassword,txtServer;
private Command cmdLogin, cmdExit, cmdClear, cmdRegister;
public LoginForm(){
form = new Form("Simple Login Form");
txtUserName=new TextField("Username", "", 255, TextField.EMAILADDR);
txtPassword=new TextField("Password", "", 255, TextField.PASSWORD);
txtServer = new TextField("Server", "", 255, TextField.ANY);
cmdClear=new Command("Clear", Command.SCREEN, 2);
cmdLogin=new Command("Login", Command.SCREEN, 1);
cmdExit=new Command("Exit", Command.EXIT, 2);
cmdRegister=new Command("Register", Command.SCREEN, 3);
form.addCommand(cmdExit);
form.addCommand(cmdClear);
form.addCommand(cmdLogin);
form.addCommand(cmdRegister);
form.append(txtUserName);
form.append(txtPassword);
form.append(txtServer);
Display.getDisplay(this).setCurrent(form);
}
public void startApp() {
}
public void pauseApp() {
}
public void destroyApp(boolean unconditional) {
}
public void commandAction(Command c, Displayable d) {
throw new UnsupportedOperationException("Not supported yet.");
}
}