brf.j2me.dynaworks.ui
Class TextBox

java.lang.Object
  |
  +--brf.j2me.dynaworks.ui.BasicWidget
        |
        +--brf.j2me.dynaworks.ui.TextBox
All Implemented Interfaces:
UserWidget
Direct Known Subclasses:
ScrollTextBox

public class TextBox
extends BasicWidget

Text box without a border.

Version:
1.0
Author:
Bernd R. Fix
See Also:
BasicWidget, UserWidget

Field Summary
protected  int breakWidth
          available width.
protected  java.lang.String delimiters
          line break characters (delimiter).
protected  int[] lineBreaks
          list of line breaks.
protected  int startLine
          first line to display.
protected  java.lang.String text
          string content.
 
Fields inherited from class brf.j2me.dynaworks.ui.BasicWidget
g, h, w, x, y
 
Constructor Summary
TextBox(java.lang.String s, int x, int y, int w, int h)
          constructor.
 
Method Summary
protected  void computeLineBreaks()
          prepare the text by breaking it into lines.
protected  int getBreakPos(int width, java.lang.String buf)
          Get the position of a line break so that the text fits into the given width.
 int getNumLines()
          get the number of lines.
 java.lang.String getText()
          get the text label.
 void paint()
          Paint the user control.
 void setText(java.lang.String s)
          set the text label.
 
Methods inherited from class brf.j2me.dynaworks.ui.BasicWidget
, contains, handleKeyDown, handlePenDown, handlePenMove, handlePenUp, handleSysKeyDown, hasFocus, loseFocus, setFocus
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, registerNatives, toString, wait, wait, wait
 

Field Detail

delimiters

protected final java.lang.String delimiters
line break characters (delimiter).


text

protected java.lang.String text
string content.


lineBreaks

protected int[] lineBreaks
list of line breaks.


breakWidth

protected int breakWidth
available width.


startLine

protected int startLine
first line to display.

Constructor Detail

TextBox

public TextBox(java.lang.String s,
               int x,
               int y,
               int w,
               int h)
constructor.

Parameters:
text - String - content of the text box.
x - int - x coordinate of upper-left corner.
y - int - y coordinate of upper-left corner.
w - int - width of the control.
h - int - height of the control.
Method Detail

setText

public void setText(java.lang.String s)
set the text label.

Parameters:
txt - String - new text content of the control.

getText

public java.lang.String getText()
get the text label.

Returns:
String - text content of the control.

getNumLines

public int getNumLines()
get the number of lines.

Returns:
int - number of lines in this box.

paint

public void paint()
Paint the user control.

Overrides:
paint in class BasicWidget

computeLineBreaks

protected void computeLineBreaks()
prepare the text by breaking it into lines.


getBreakPos

protected int getBreakPos(int width,
                          java.lang.String buf)
Get the position of a line break so that the text fits into the given width.

Parameters:
width - int - maximum width of line.
buf - String - content to be split.
Returns:
int - break index (or 0 if no break found).