A TextField
is a text component that is
editable when it is focused on. It provides the same editing operations
as TextBox
and follows the same specification to the
extent that TextField
s can practically be considered TextBox
es that are inserted into a Form
. It can have an initial value that is displayed at initialisation. TextField
s are always the same width as the Form
they are placed in, but the amount of rows they use
can be set.
TextField
is always focusable.
Touch down and release on an editable TextField
activates the field for editing.
On Series 40 touch and type, by default, touch down and release activates in-line editing.
Touch down and release within the selected TextField
moves the text cursor to the point of the tap, provided that there
is some text on that point. If there is no text and the user taps
the empty space of the TextField
the cursor moves
to the end of the text.
On Series 40 touch and type devices, text can be edited by
using the physical keypad. On Series 40 full touch and Nokia Asha
software platform devices, you can edit the text through the VirtualKeyboard
, that becomes visible when the user taps
the TextField
.
If a TextField
has multiple commands assigned
to it, touch down and hold on the TextField
opens
a pop-up menu containing the commands. The pop-up menu corresponds
to the context-specific Option's menu of non-touch devices.
TextField
s are meant for single line text
input and do not support a scrollbar.Figure: A TextField example full screen mode
Figure: A TextField example Split view
import javax.microedition.midlet.*; import javax.microedition.lcdui.*; public class ExampleMIDlet extends MIDlet implements CommandListener { private Display display; private Form form; private Command exit; private TextField field; public ExampleMIDlet() { form = new Form("Form example 6"); field = new TextField("Please input a value", "", 16, TextField.ANY); form.append(field); exit = new Command("Exit", Command.EXIT, 1); form.addCommand(exit); form.setCommandListener(this); } public void startApp() { display = Display.getDisplay(this); display.setCurrent(form); } public void pauseApp() { } public void destroyApp(boolean unconditional) { } public void commandAction(Command command, Displayable displayable) { if (command == exit) { destroyApp(false); notifyDestroyed(); } } }
For more information about TextField see: