本文整理匯總了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);
}
}