use*_*579 5 java editor netbeans-platform
如何获取插入符号在NetBeans编辑器中的行号.我正在开发一个net bean插件,我需要获取插入符号(而不是鼠标)的位置.
从您使用的编辑器 cookie 获取当前窗格,例如:
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 );
}
}
Run Code Online (Sandbox Code Playgroud)
问候,@tmmg