Perhaps this might help..
http://seminars.jguru.com/forums/view.jsp?EID=1247896
Regards,
Robert
> I try to get the line number of current that cursor is on from the
> JEditorPane.
> I found method getSelectionStart() and getSelectedText(), but it not
> has the getSelectedLine() or ...
This depends on your document. E.g. if you use a
javax.swing.text.PlainDocument, then it should be easy:
JEditorPane editor = ...
PlainDocument doc = (PlainDocument) editor.getDocument();
int offset = editor.getCaretPosition();
int lineNbr = doc.getDefaultRootElement().getElementIndex(offset);
Other document types behave totally different. E.g. HTMLDocument builds
a hierarchical Element structure where each Element represents a
structural block of HTML, and not just a line of text.
/Thomas

Signature
The comp.lang.java.gui FAQ:
ftp://ftp.cs.uu.nl/pub/NEWS.ANSWERS/computer-lang/java/gui/faq
http://www.uni-giessen.de/faq/archiv/computer-lang.java.gui.faq/