本文整理汇总了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 ();
}
示例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();
}
示例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;
}
示例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));
}
示例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);
}
}