javax.swing.JEditorPane.getCaret()方法的使用及代码示例

x33g5p2x  于2022-01-21 转载在 其他  
字(6.9k)|赞(0)|评价(0)|浏览(141)

本文整理了Java中javax.swing.JEditorPane.getCaret()方法的一些代码示例,展示了JEditorPane.getCaret()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。JEditorPane.getCaret()方法的具体详情如下:
包路径:javax.swing.JEditorPane
类名称:JEditorPane
方法名:getCaret

JEditorPane.getCaret介绍

暂无

代码示例

代码示例来源:origin: ron190/jsql-injection

@Override
  public void focusGained(FocusEvent arg0) {
    text[0].getCaret().setVisible(true);
    text[0].getCaret().setSelectionVisible(true);
  }
});

代码示例来源:origin: bobbylight/RSyntaxTextArea

textArea.getCaret().setSelectionVisible(true);

代码示例来源:origin: org.netbeans.modules/org-netbeans-modules-cnd-debugger-common2

public void focusGained(java.awt.event.FocusEvent e) {
// DEBUG System.out.printf("disasm: focusGained()\n");
editorPane.getCaret().setVisible(true);
}
public void focusLost(java.awt.event.FocusEvent e) {

代码示例来源:origin: org.netbeans.modules/org-netbeans-modules-kenai-ui

private void issuesInfoPaneFocusGained(java.awt.event.FocusEvent evt) {//GEN-FIRST:event_issuesInfoPaneFocusGained
  issuesInfoPane.getCaret().setVisible(false);
}//GEN-LAST:event_issuesInfoPaneFocusGained

代码示例来源:origin: org.netbeans.modules/org-netbeans-modules-kenai-ui

private void commChannelsDisplayerFocusGained(java.awt.event.FocusEvent evt) {//GEN-FIRST:event_commChannelsDisplayerFocusGained
  commChannelsDisplayer.getCaret().setVisible(false); //MacOSX hack
}//GEN-LAST:event_commChannelsDisplayerFocusGained

代码示例来源:origin: org.netbeans.modules/org-netbeans-modules-cnd-debugger-common2

/**
 * Return the contents of the line under the cursor.
 */
private String getCurrentLine() {
Caret caret = editorPane.getCaret();
int pos = caret.getDot();
return getLineAt(pos);
}

代码示例来源:origin: org.netbeans.modules/org-netbeans-modules-web-core

public void actionPerformed(java.awt.event.ActionEvent e) {
    if (lastCaretOffset == -1 && pane != null) {
      Caret caret = pane.getCaret();
      if (caret != null)
        lastCaretOffset = caret.getDot();
    }
    selectElementsAtOffset(lastCaretOffset);
  }
});

代码示例来源:origin: eu.mihosoft.vrl/vrl

@Override
public void mouseClicked(MouseEvent e) {
  getEditor().getCaret().setVisible(true);
}

代码示例来源:origin: dcaoyuan/nbscala

/**
 * Returns number of line currently selected in editor or <code>-1</code>.
 *
 * @return number of line currently selected in editor or <code>-1</code>
 */
public int getCurrentOffset() {
  JEditorPane ep = contextDispatcher.getCurrentEditor();
  if (ep == null) {
    return -1;
  }
  Caret caret = ep.getCaret();
  if (caret == null) {
    return -1;
  }
  return caret.getDot();
}

代码示例来源:origin: org.netbeans.modules/org-netbeans-modules-cnd-navigation

private int getOffset(Node[] activatedNodes) {
  EditorCookie c = activatedNodes[0].getLookup().lookup(EditorCookie.class);
  if (c != null) {
    JEditorPane pane = CsmUtilities.findRecentEditorPaneInEQ(c);
    if (pane != null ) {
      return pane.getCaret().getDot();
    }
  }
  return 0;
}

代码示例来源:origin: org.netbeans.modules/org-netbeans-modules-debugger-jpda-projects

/**
 * Returns number of line currently selected in editor or <code>-1</code>.
 *
 * @return number of line currently selected in editor or <code>-1</code>
 */
public int getCurrentOffset () {
  JEditorPane ep = contextDispatcher.getCurrentEditor();
  if (ep == null) {
    return -1;
  }
  Caret caret = ep.getCaret ();
  if (caret == null) {
    return -1;
  }
  return caret.getDot();
}

代码示例来源:origin: org.netbeans.modules/org-netbeans-modules-debugger-jpda-projectsui

/**
 * Returns number of line currently selected in editor or <code>-1</code>.
 *
 * @return number of line currently selected in editor or <code>-1</code>
 */
public int getCurrentOffset () {
  JEditorPane ep = contextDispatcher.getCurrentEditor();
  if (ep == null) {
    return -1;
  }
  Caret caret = ep.getCaret ();
  if (caret == null) {
    return -1;
  }
  return caret.getDot();
}

代码示例来源:origin: org.netbeans.modules/org-netbeans-modules-cnd-navigation

public static CsmScope findScope(Node activatedNode) {
  EditorCookie c = activatedNode.getLookup().lookup(EditorCookie.class);
  if (c != null) {
    JEditorPane pane = CsmUtilities.findRecentEditorPaneInEQ(c);
    if (pane != null ) {
      int offset = pane.getCaret().getDot();
      CsmFile file = CsmUtilities.getCsmFile(activatedNode,false);
      if (file != null){
        return findInnerFileScope(file, offset);
      }
    }
  }
  return null;
}

代码示例来源:origin: org.netbeans.modules/org-netbeans-modules-cnd-navigation

public static CsmDeclaration findDeclaration(Node activatedNode) {
  EditorCookie c = activatedNode.getLookup().lookup(EditorCookie.class);
  if (c != null) {
    JEditorPane pane = CsmUtilities.findRecentEditorPaneInEQ(c);
    if (pane != null ) {
      int offset = pane.getCaret().getDot();
      CsmFile file = CsmUtilities.getCsmFile(activatedNode,false);
      if (file != null){
        return findInnerFileDeclaration(file, offset);
      }
    }
  }
  return null;
}

代码示例来源:origin: org.netbeans.modules/org-netbeans-modules-web-debug

public static boolean isScriptlet() {
  JEditorPane ep = EditorContextDispatcher.getDefault().getCurrentEditor();
  if (ep == null) {
    return false;
  }
  return isScriptlet(
    (StyledDocument) ep.getDocument (),
    ep,
    ep.getCaret ().getDot ()
  );
}

代码示例来源:origin: org.netbeans.modules/org-netbeans-modules-web-debug

public static String getJavaIdentifier () {
  JEditorPane ep = EditorContextDispatcher.getDefault().getCurrentEditor();
  if (ep == null) {
    return null;
  }
  return getJavaIdentifier (
    (StyledDocument) ep.getDocument (),
    ep,
    ep.getCaret ().getDot ()
  );
}

代码示例来源:origin: org.netbeans.api/org-netbeans-modules-languages

public void run() {
    AbstractDocument doc = getCurrentDocument ();
    TokenSequence ts = null;
    if (doc != null)
      try {
        doc.readLock ();
        TokenHierarchy tokenHierarchy = TokenHierarchy.get (doc);
        if (tokenHierarchy == null) return;
        ts = tokenHierarchy.tokenSequence ();
      } finally {
        doc.readUnlock ();
      }
    if (ts == null)
      tree.setModel (new DefaultTreeModel (new DefaultMutableTreeNode ()));
    else
      tree.setModel (new DefaultTreeModel (new TSNode (null, ts, null, 0, 0)));
    JEditorPane editor = getCurrentEditor ();
    if (editor != null) {
      int position = getCurrentEditor ().getCaret ().getDot ();
      selectPath (position);
    }
  }
});

代码示例来源:origin: org.netbeans.modules/org-netbeans-modules-cnd-classview

private static CsmOffsetableDeclaration findDeclaration(Node activatedNode) {
  EditorCookie c = activatedNode.getCookie(EditorCookie.class);
  if (c != null) {
    JEditorPane pane = CsmUtilities.findRecentEditorPaneInEQ(c);
    if (pane != null ) {
      int offset = pane.getCaret().getDot();
      CsmFile file = CsmUtilities.getCsmFile(activatedNode,false);
      if (file != null){
        return findInnerFileDeclaration(file, offset);
      }
    }
  }
  return null;
}

代码示例来源:origin: org.netbeans.modules/org-netbeans-modules-groovy-support

static boolean canHandle(Node activatedNode) {
  FileObject fo = getFileObjectFromNode(activatedNode);
  if (fo != null) {
    if (!isGroovyFile(fo)) {
      return false;
    }
    EditorCookie ec = activatedNode.getLookup().lookup(EditorCookie.class);
    if (ec != null) {
      JEditorPane pane = NbDocument.findRecentEditorPane(ec);
      if (pane != null) {
        SingleMethod sm = getTestMethod(pane.getDocument(), pane.getCaret().getDot());
        if(sm != null) {
          return true;
        }
      }
    }
  }
  return false;
}

代码示例来源:origin: org.netbeans.modules/org-netbeans-modules-cnd-debugger-common2

public static Line getCurrentLine() {
EditorCookie e = getCurrentEditorCookie();
if (e == null)
  return null;
JEditorPane ep = getCurrentEditor(e);
if (ep == null)
  return null;
StyledDocument d = e.getDocument();
if (d == null)
  return null;
int lineNo = NbDocument.findLineNumber(d, ep.getCaret().getDot());
// Editor numbers lines from 0!
Line l = null;
try {
  l = e.getLineSet().getCurrent(lineNo + 1);
} catch (IndexOutOfBoundsException x) {
  // 6494346
}
return l;
}

相关文章

JEditorPane类方法