FileDocCategorySizeDatePackage
TextCursor.javaAPI DocJ2ME MIDP 2.01968Thu Nov 07 12:02:22 GMT 2002com.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
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;
        }
    
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


        int stroke = g.getStrokeStyle();
        g.setStrokeStyle(g.SOLID);
        g.drawLine(x - 1, y - height, (x - 1) + (width - 1), y);
        g.setStrokeStyle(stroke);