当前位置: 首页>>代码示例>>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;未经允许,请勿转载。