Line-by-line Anatomy of HelloMIDlet.java
(Cont.)
tbxMain = new TextBox("HelloMIDlet", "Hello, World!", 50, 0);
The constructor public javax.microedition.lcdui.TextBox(String title, String text, int maxSize, int constraints) creates a new TextBox
object with the following parameters:
title
— The title text is to be shown with the display.
text
— The initial contents of the text editing area.
If the text parameter is null, the TextBox
is created empty.
maxSize
— The maximum capacity in characters, which must be greater than zero.
constraints
— The different constraints allow the application to request that the user's input be restricted in a variety of ways.
Constant 0 is assigned to public static final int ANY
, which allows users to enter any text.
Other constraints can be found from the Field Summary of input constraints.
tbxMain.addCommand(cmdExit);
The method public void javax.microedition.lcdui.Displayable.addCommand (Command cmd) adds a command to the Displayable.
The implementation may choose, for example, to add the command to any of the available soft buttons or place it in a menu.
tbxMain.setCommandListener(this);
The method public void javax.microedition.lcdui.Displayable.setCommandListener (CommandListener l) sets a listener for Commands
to this Displayable
, replacing any previous CommandListener
.
public void startApp( ) {
The MIDlet enters the Active
state after the application manager calls startApp( )
via clicking on the button Launch
.