Row and Col count

Hi guys... i am using a Text Plane as my GUI component ...

How can i get the row count and column count of the current caret location.

[147 byte] By [CodeXa] at [2007-11-27 11:46:47]
# 1

int pos = textpane.getCaretPosition();

Document doc = textpane.getDocument();

Element root = doc.getRootElements()[0];

for (int row = 0; row < root.getElementCount(); row++) {

Element line = root.getElement(row);

int start = line.getStartOffset();

int end = line.getEndOffset();

if(pos >= start && pos < end){

int column = pos-start;

System.out.println("["+row+","+column+"]");

break;

}

}

Andre_Uhresa at 2007-7-29 18:09:30 > top of Java-index,Desktop,Core GUI APIs...
# 2

Did you bother searching the forums first?

The keywords to use are already in your question. Words like "row column" and the component name you are using.

camickra at 2007-7-29 18:09:30 > top of Java-index,Desktop,Core GUI APIs...