Monday, 16 January 2012



J2ME Program to Display TextField
import javax.microedition.midlet.*;
import javax.microedition.lcdui.*;
public class TextDemo extends MIDlet implements CommandListener
{
  private Display display;
  private TextField t2;
  private Form f1;
  private Command CMD_EXIT=new   Command("EXIT",Command.EXIT,1);
          public TextDemo()
          {
                   display=Display.getDisplay(this);
          }
          protected void startApp()
          {
                   t2=new TextField("NAME","  ",40,TextField.ANY);
                   f1=new Form("TEXT BOX DEMO");
                   f1.append(t2);
                   f1.addCommand(CMD_EXIT);
                   f1.setCommandListener(this);
                   display.setCurrent(f1);
          }
          protected void pauseApp(){}
          protected void destroyApp(boolean  unconditional) {}
          public void commandAction(Command c,Displayable d){
                    if(c==CMD_EXIT)
                   {
                             destroyApp(true);
                   }}}
OUTPUT

Related Posts :



0 comments:

Confused? Feel free to ask

Post a Comment