TextField vs TextBox (2)
23 April 2008I 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);
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.
Related Posts:
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)