當前位置: 首頁>>代碼示例>>Java>>正文


Java JEditorPane.addCaretListener方法代碼示例

本文整理匯總了Java中javax.swing.JEditorPane.addCaretListener方法的典型用法代碼示例。如果您正苦於以下問題:Java JEditorPane.addCaretListener方法的具體用法?Java JEditorPane.addCaretListener怎麽用?Java JEditorPane.addCaretListener使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在javax.swing.JEditorPane的用法示例。


在下文中一共展示了JEditorPane.addCaretListener方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: getCurrentRootNode

import javax.swing.JEditorPane; //導入方法依賴的package包/類
private ASTNode getCurrentRootNode () {
    Node[] ns = TopComponent.getRegistry ().getActivatedNodes ();
    if (ns.length != 1) return null;
    EditorCookie editorCookie = ns [0].getLookup ().
        lookup (EditorCookie.class);
    if (editorCookie == null) return null;
    if (editorCookie.getOpenedPanes () == null) return null;
    if (editorCookie.getOpenedPanes ().length < 1) return null;
    JEditorPane pane = editorCookie.getOpenedPanes () [0];
    if (caretListener == null)
        caretListener = new CListener ();
    if (lastPane != null && lastPane != pane) {
        lastPane.removeCaretListener (caretListener);
        lastPane = null;
    }
    if (lastPane == null) {
        pane.addCaretListener (caretListener);
        lastPane = pane;
    }
    Document document = editorCookie.getDocument ();
    if (document == null || !(document instanceof NbEditorDocument)) return null;
    return ParserManagerImpl.getImpl (document).getAST ();
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:24,代碼來源:ASTBrowserTopComponent.java

示例2: createTab

import javax.swing.JEditorPane; //導入方法依賴的package包/類
private void createTab()
  {
  jep=new JEditorPane();
  jsp=new JScrollPane(jep);
  panes.add(jsp);
 jep.setContentType("text/plain");
typeOFileLabel.setText("Plain Text File");
  editorPanes.add(jep);
  new CaretMonitor(jep, caretPosLabel);
     jep.addCaretListener(this);
jep.getDocument().addUndoableEditListener((UndoableEditEvent uee) -> {
    undo.addEdit(uee.getEdit());   });
  tabbedPane.addTab("*Tab "+(ct+1),jsp);
  tabbedPane.setSelectedIndex(ct);
  tabbedPane.setTabComponentAt(ct,new ButtonTabComponent(tabbedPane));
  ct++;
  setToolbar();
  }
 
開發者ID:ksaluja24,項目名稱:scratch-bench,代碼行數:19,代碼來源:MainMenu.java

示例3: getCurrentDocument

import javax.swing.JEditorPane; //導入方法依賴的package包/類
private AbstractDocument getCurrentDocument () {
    Node[] ns = TopComponent.getRegistry ().getActivatedNodes ();
    if (ns.length != 1) return null;
    EditorCookie editorCookie = ns [0].getLookup ().
        lookup (EditorCookie.class);
    if (editorCookie == null) return null;
    if (editorCookie.getOpenedPanes () == null) return null;
    if (editorCookie.getOpenedPanes ().length < 1) return null;
    JEditorPane pane = editorCookie.getOpenedPanes () [0];
    
    if (caretListener == null)
        caretListener = new CListener ();
    if (lastPane != null && lastPane != pane) {
        lastPane.removeCaretListener (caretListener);
        lastPane = null;
    }
    if (lastPane == null) {
        pane.addCaretListener (caretListener);
        lastPane = pane;
    }

    AbstractDocument doc = (AbstractDocument) editorCookie.getDocument ();
    if (documentListener == null)
        documentListener = new CDocumentListener ();
    if (lastDocument != null && lastDocument != doc) {
        lastDocument.removeDocumentListener (documentListener);
        lastDocument = null;
    }
    if (lastDocument == null) {
        doc.addDocumentListener (documentListener);
        lastDocument = doc;
    }
    return doc;
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:35,代碼來源:TokensBrowserTopComponent.java

示例4: install

import javax.swing.JEditorPane; //導入方法依賴的package包/類
public @Override void install (JEditorPane c) {
    super.install (c);
    HyperlinkListener hl = new HyperlinkListener ();
    c.addMouseMotionListener (hl);
    c.addMouseListener (hl);
    c.addKeyListener(hl);
    c.addCaretListener (new MarkOccurrencesSupport (c));
}
 
開發者ID:apache,項目名稱:incubator-netbeans,代碼行數:9,代碼來源:LanguagesEditorKit.java

示例5: install

import javax.swing.JEditorPane; //導入方法依賴的package包/類
/**
 * Called when the kit is being installed into
 * a JEditorPane.
 *
 * @param c the JEditorPane
 */
public void install(JEditorPane c) {
    c.addCaretListener(inputAttributeUpdater);
    c.addPropertyChangeListener(inputAttributeUpdater);
    Caret caret = c.getCaret();
    if (caret != null) {
        inputAttributeUpdater.updateInputAttributes
                              (caret.getDot(), caret.getMark(), c);
    }
}
 
開發者ID:SunburstApps,項目名稱:OpenJSharp,代碼行數:16,代碼來源:StyledEditorKit.java


注:本文中的javax.swing.JEditorPane.addCaretListener方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。