TextField vs TextBox (2)

23 April 2008

I will write about TextBox (javax.microedition.lcdui.TextBox). This class inherits from javax.microedition.lcdui.Screen, so you should know that its a Screen and unlike TextField, it cannot be appended to a Form.

To create an instance of TextBox, we use the TextBox constructor:

TextBox(String label, String text, int maxSize, int constraints)

The parameters are self explainatory. Let me present an example:

...
Display display;
TextBox textBox;
...
protected void startApp() throws MIDletStateChangeException {
System.out.println("startApp.");
display = Display.getDisplay(this);
form = new Form("Helloworld example");
StringItem body = new StringItem(null,"Hello World!");
textBox = new TextBox("Location", "your location", 15, 0); 
 
display.setCurrent(textBox);

Output:
TextBox example

So use TextBox when you want to take input from the user without using Form. Since TextBox is a Screen, you may append commands on it as well.

del.icio.us:TextField vs TextBox (2)  digg:TextField vs TextBox (2)  spurl:TextField vs TextBox (2)  wists:TextField vs TextBox (2)  simpy:TextField vs TextBox (2)  newsvine:TextField vs TextBox (2)  blinklist:TextField vs TextBox (2)  furl:TextField vs TextBox (2)  reddit:TextField vs TextBox (2)  fark:TextField vs TextBox (2)  blogmarks:TextField vs TextBox (2)  Y!:TextField vs TextBox (2)  smarking:TextField vs TextBox (2)  magnolia:TextField vs TextBox (2)  segnalo:TextField vs TextBox (2)  gifttagging:TextField vs TextBox (2)

Top Of Page | Trackback

If you found this page useful, consider linking to it. Simply copy and paste the code below into your web site.

It will look like this: TextField vs TextBox (2)

Leave a Reply