How to create a TextBox in Java ME
Article Metadata
Compatibility
Platform(s): Java ME
Article
Created: giaperrucci
(07 Jun 2007)
Last edited: hamishwillee
(29 Aug 2012)
This article shows how to create a text box in Java ME.
import javax.microedition.midlet.*;
import javax.microedition.lcdui.*;
public class TextBox_Example extends MIDlet
{
Display display=Display.getDisplay(this);
public void startApp()
{
//TextBox(title,text,size,contrains)
TextBox textbox = new TextBox("Text Box Example",
"This is an example of a TextBox",50,0);
display.setCurrent(textbox);
}
}



29 Sep
2009
This article sows a complete code example on creating a Text Box in j2me. Text box is a very basic UI element j2m2. The main class used is "TextBox" then its constructor takes height and width of the text box with optional pre-loaded text.
Given code is perfect as per j2me code standards and conventions. It runs and display text box as described in this article. A snapshot is given of code example for better understanding of reader.