I am looking for a method that calculates the line number of a given text position in a JTextPane with wrapper enabled.
Example:
It is very very very very very very very very very very very very very very very very very very very very long. It is still very very very very very very very very very very very very very very very long. |
The cursor is on line number four, not two.
Can someone provide me with an implementation of the method:
int getLineNumber(JTextPane pane, int pos)
{
return ???
}
source
share