FileDocCategorySizeDatePackage
TextCursor.javaAPI DocphoneME MR2 API (J2ME)2976Wed May 02 18:00:20 BST 2007com.sun.midp.lcdui

TextCursor

public class TextCursor extends Object
Class that represents the character index, and (x,y) position of a text cursor in a TextField

Fields Summary
public int
x
x, y coordinates
public int
y
public int
width
width, height
public int
height
public int
index
array index
public int
option
drawing options: can be one of the PAINT_* variables in Text.java
public boolean
visible
whether or not this cursor is visible
public int
preferredX
preferred x location when traversing vertically
public int
yOffset
yOffset to modify paint by for calculating h value
Constructors Summary
public TextCursor(int index)
Construct a new text cursor with the given array index

param
index index into the array that this cursor will be drawn

        this.index = index;
        option = Text.PAINT_USE_CURSOR_INDEX;
        visible = true;
    
public TextCursor(TextCursor tc)
Copy a TextCursor object

param
tc TextCursor object to copy

        this(0);

        if (tc != null) {
            this.x       = tc.x;
            this.y       = tc.y;
            this.option  = tc.option;
            this.index   = tc.index;
            this.visible = tc.visible;
	    this.preferredX = tc.preferredX;
	    this.yOffset = tc.yOffset;
        }
    
Methods Summary
public voidpaint(javax.microedition.lcdui.Graphics g)
Paint this cursor in the given graphics context

param
g the graphics context to paint in

        // Stroke should already be SOLID
        g.setColor(TextFieldSkin.COLOR_FG);
        g.fillRect(x, y - yOffset - height + 2, 
                   TextFieldSkin.WIDTH_CARET, height - 3);
        g.setColor(0); // back to default black