ch.aplu.gidlet
Class MTextBox

java.lang.Object
  extended by javax.microedition.lcdui.Displayable
      extended by javax.microedition.lcdui.Screen
          extended by javax.microedition.lcdui.TextBox
              extended by ch.aplu.gidlet.MTextBox

public class MTextBox
extends javax.microedition.lcdui.TextBox

TextBox display for full screen input and output. Text may be edited using the platform's editing capabilities.

A soft button 'Exit' is shown. Hitting the corresponding key will call the Gidlet's doExit(). If you do not need this button, invoke removeExitButton().

If you implement your own CommandListener and call setCommandListener(), the internal CommandListener is disabled.

main() serves as entry point for the user programm. It is called in the run-method of a separate thread and should terminate to avoid non-terminated threads.

Creation may take place within main() or when declaring instance variables of the application program.


Constructor Summary
MTextBox(java.lang.String title)
          Constructs a MTextBox with given title and no initial text.
MTextBox(java.lang.String title, java.lang.String text)
          Constructs a MTextBox with given title and given initial text.
 
Method Summary
 void addOkButton()
          Adds an OK soft button with label "OK".
 void addOkButton(java.lang.String label)
          Adds an OK soft button with given label.
 void appendText(java.lang.String text)
          Appends given text to current content.
 java.lang.String getText()
          Returns current content.
 void removeExitButton()
          Removes Exit soft button.
 void removeOkButton()
          Removes Ok soft button.
 void setText(java.lang.String text)
          Writes given text replacing the previous content.
 void show()
          Shows the form display if it is not yet visible or it was previously hidden by another display.
 void show(boolean wait)
          Shows the form display if it is not yet visible or it was previously hidden by another display.
 
Methods inherited from class javax.microedition.lcdui.TextBox
delete, getCaretPosition, getChars, getConstraints, getMaxSize, getString, insert, insert, setChars, setConstraints, setInitialInputMode, setMaxSize, setString, setTicker, setTitle, size
 
Methods inherited from class javax.microedition.lcdui.Displayable
addCommand, getHeight, getTicker, getTitle, getWidth, isShown, removeCommand, setCommandListener, sizeChanged
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

MTextBox

public MTextBox(java.lang.String title,
                java.lang.String text)
Constructs a MTextBox with given title and given initial text. The display is initially invisible and should be made visible by calling show().


MTextBox

public MTextBox(java.lang.String title)
Constructs a MTextBox with given title and no initial text. The display is initially invisible and should be made visible by calling show().

Method Detail

show

public void show()
Shows the form display if it is not yet visible or it was previously hidden by another display. Because it is not garanteed that the diplay is actually visible when Display.setCurrent() returns, wait for a maximum of 5 s for the display to get shown.


show

public void show(boolean wait)
Shows the form display if it is not yet visible or it was previously hidden by another display. If wait = true, block until the display becomes actually visible, up to a maximum auf 5 seconds. This may be useful to observe the start of an animation.


getText

public java.lang.String getText()
Returns current content.


setText

public void setText(java.lang.String text)
Writes given text replacing the previous content. If the length of the text exceeds the maximal size granted by the platform, the text is truncated. If the text exceeds the height if the display, the first line is on the top and the text may be scrolled using a small scroll icon. Lines are separated by the plattform's line separator. If the length of a line exceeds the width of the display, the line wraps at word boundaries.
Newline character '\n' is supported to force a line wrap.


appendText

public void appendText(java.lang.String text)
Appends given text to current content. If the length of the total text exceeds the maximal size granted by the platform, the text is truncated. If the text exceeds the height if the display, the first line is on the top and the text may be scrolled using a small scroll icon. Lines are separated by the plattform's line separator. If the length of a line exceeds the width of the display, the line wraps at word boundaries.
Newline character '\n' is supported to force a line wrap.


addOkButton

public void addOkButton()
Adds an OK soft button with label "OK". When pressed, the Gidlet's callback notification doOk() is called unless you register your own CommandListener.


addOkButton

public void addOkButton(java.lang.String label)
Adds an OK soft button with given label. When pressed, the Gidlet's callback notification doOk() is called unless you register your own CommandListener.


removeExitButton

public void removeExitButton()
Removes Exit soft button. Gidlet's callback notification doExit() is disabled.


removeOkButton

public void removeOkButton()
Removes Ok soft button. Gidlet's callback notification doOk() is disabled.