com.nokia.midp.examples.lcdui.helloworldplus
Class TextScreen

java.lang.Object
  extended byjavax.microedition.lcdui.Displayable
      extended byjavax.microedition.lcdui.Screen
          extended byjavax.microedition.lcdui.Form
              extended bycom.nokia.midp.examples.lcdui.helloworldplus.TextScreen
All Implemented Interfaces:
javax.microedition.lcdui.CommandListener

public class TextScreen
extends javax.microedition.lcdui.Form
implements javax.microedition.lcdui.CommandListener

The TextScreen class displays a message on the screen.

This class extends the Form class and uses an instance of StringItem to display the text message. The Form with StringItem implementation was chosen because it allows a non-editable text message to be written onto the screen.

The text message can set via the constructor and setCurrentText() method.


Field Summary
private static javax.microedition.lcdui.Command CMD_EDIT
          Command specified to initiate the launch of the TextEditor screen.
private static javax.microedition.lcdui.Command CMD_EXIT
          Command specified to initiate the termination of the MIDlet.
private static int COMMAND_PRIORITY
          Priority of commands relative to others of the same type.
private  HelloWorldPlusMIDlet midlet
          Reference to the parent MIDlet class enabling this class to access the callback methods provided by HelloWorldMIDlet.
private  javax.microedition.lcdui.StringItem stringItem
          Reference to the string item added to the form for displaying a message.
 
Fields inherited from class javax.microedition.lcdui.Form
 
Fields inherited from class javax.microedition.lcdui.Displayable
 
Constructor Summary
(package private) TextScreen(HelloWorldPlusMIDlet midlet, java.lang.String message)
          The constructor initializes the class making it ready for use.
 
Method Summary
 void commandAction(javax.microedition.lcdui.Command cmd, javax.microedition.lcdui.Displayable source)
          Handles commands received.
 java.lang.String getCurrentText()
          Returns the text currently displayed
 void setCurrentText(java.lang.String message)
          Sets the text to be displayed.
 
Methods inherited from class javax.microedition.lcdui.Form
append, append, append, delete, deleteAll, get, getHeight, getWidth, insert, set, setItemStateListener, size
 
Methods inherited from class javax.microedition.lcdui.Displayable
addCommand, getTicker, getTitle, isShown, removeCommand, setCommandListener, setTicker, setTitle, sizeChanged
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

stringItem

private javax.microedition.lcdui.StringItem stringItem
Reference to the string item added to the form for displaying a message.


midlet

private final HelloWorldPlusMIDlet midlet
Reference to the parent MIDlet class enabling this class to access the callback methods provided by HelloWorldMIDlet.


COMMAND_PRIORITY

private static final int COMMAND_PRIORITY
Priority of commands relative to others of the same type.

See Also:
Constant Field Values

CMD_EXIT

private static final javax.microedition.lcdui.Command CMD_EXIT
Command specified to initiate the termination of the MIDlet.


CMD_EDIT

private static final javax.microedition.lcdui.Command CMD_EDIT
Command specified to initiate the launch of the TextEditor screen.

Constructor Detail

TextScreen

TextScreen(HelloWorldPlusMIDlet midlet,
           java.lang.String message)
The constructor initializes the class making it ready for use.

It initializes the reference to the parent MIDlet class with the paramater value 'midlet'.
It creates an instance of the class ItemString and initializes it with the parameter value 'message'.
It appends the created instance of ItemString to the form.
It adds the Command objects defined to the command handling framework.
It calls setCommandListener() to register itself with the command framework as the command listener and will be notified when a command is activated.

Parameters:
midlet - is a reference to the parent MIDlet. Enables callback to parent object.
message - sets displayed text.
Method Detail

setCurrentText

public void setCurrentText(java.lang.String message)
Sets the text to be displayed.


getCurrentText

public java.lang.String getCurrentText()
Returns the text currently displayed


commandAction

public void commandAction(javax.microedition.lcdui.Command cmd,
                          javax.microedition.lcdui.Displayable source)
Handles commands received.

The CMD_EXIT command initiates the termination of the MIDlet. The method handles this command by calling the parent method exitRequested().

The CMD_EDIT command initiates the launch of the TextEditor screen. The method handles this command by calling the parent method textEditorRequested().

Specified by:
commandAction in interface javax.microedition.lcdui.CommandListener
Parameters:
cmd - is the identity of command received from the framework.
source - is the identity of the UI area displayed which generated the command.