How can I get the line number in which the caret is in NetBeans editor.I am developing a net bean plugin and I need to get the position of the caret( not mouse ).
Get the current pane from editor cookie you use, e.g:
try {
StyledDocument doc = editorCookie.openDocument();
if (editorCookie != null) {
JEditorPane[] panes = editorCookie.getOpenedPanes();
if (panes.length > 0) {
int linenumber = panes[0].getCaret().getDot();
doc.insertString( linenumber, "emagenio.com", null );
}
}
Regards, @tmmg
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With