Java Code Examples for javax.swing.event.CaretEvent#getDot()

The following examples show how to use javax.swing.event.CaretEvent#getDot() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: GUIController.java    From codebuff with BSD 2-Clause "Simplified" License 6 votes vote down vote up
@Override
public void caretUpdate(CaretEvent e) {
	int cursor = e.getDot();
	JTextPane textPane = (JTextPane)e.getSource();
	TokenPositionAnalysis analysis = getAnalysisForCharIndex(cursor);
	Highlighter highlighter = textPane.getHighlighter();
	HighlightPainter painter = new DefaultHighlightPainter(Color.orange);
	try {
		highlighter.removeAllHighlights();
		if ( analysis!=null ) {
			highlighter.addHighlight(analysis.charIndexStart, analysis.charIndexStop+1, painter);
		}
		scope.injectNLConsole.setText(analysis!=null ? analysis.wsAnalysis : "");
		scope.injectNLConsole.setCaretPosition(0);
		scope.alignConsole.setText(analysis!=null ? analysis.alignAnalysis : "");
		scope.alignConsole.setCaretPosition(0);
	}
	catch (Exception ex) {
		ex.printStackTrace(System.err);
	}
}
 
Example 2
Source File: TextPanelCaretListener.java    From mae-annotation with GNU General Public License v3.0 6 votes vote down vote up
@Override
public void caretUpdate(CaretEvent e) {

    try {
        if (e.getDot() != e.getMark()) { // that is, mouse is dragged and text is selected
            addDraggedSelection(e.getDot(), e.getMark());
        } else if (mainController.getMode() == MaeMainController.MODE_MULTI_SPAN) {
            // MSPAN mode always ignore single click
        } else {
            if (mainController.getMode() == MaeMainController.MODE_NORMAL) {
                textPanelController.clearSelection(); // single click will clear out prev selection
            }
            if (acceptingSingleClick()) {
                textPanelController.addSelection(new int[]{e.getDot(), e.getDot() + 1});
            }
        }
    } catch (MaeDBException ex) {
        mainController.showError(ex);
    }
    textPanelController.repaintBGColor();
    mainController.propagateSelectionFromTextPanel();
}
 
Example 3
Source File: POMModelPanel.java    From netbeans with Apache License 2.0 5 votes vote down vote up
@Override
public void caretUpdate(CaretEvent e) {
    JTextComponent cc = currentComponent != null ? currentComponent.get() : null;
    if (e.getSource() != cc) {
        ((JTextComponent)e.getSource()).removeCaretListener(this);
        //just a double check we do't get a persistent leak here..
        return;
    }
    currentDot = e.getDot();
    caretTask.schedule(1000);
}
 
Example 4
Source File: ComponentPeer.java    From netbeans with Apache License 2.0 5 votes vote down vote up
public void caretUpdate(CaretEvent e) {
    synchronized (this) {
        lastCaretPosition = e.getDot();
    }
    
    LOG.fine("scheduling hints computation");
    
    computeHint.schedule(100);
}
 
Example 5
Source File: TokensBrowserTopComponent.java    From netbeans with Apache License 2.0 5 votes vote down vote up
public void caretUpdate (CaretEvent e) {
    int position = e.getDot ();
    try {
        selectPath (position);
    } catch (ConcurrentModificationException ex) {
    }
}
 
Example 6
Source File: MarkOccurrences.java    From netbeans with Apache License 2.0 5 votes vote down vote up
@Override
public synchronized void caretUpdate(CaretEvent e) {
    caretPos = e.getDot();
    WORKER.post(() -> {
        FileObject file = NbEditorUtilities.getFileObject(doc);

        if (file != null) {
            LSPBindings.rescheduleBackgroundTask(file, this);
        }
    });
}
 
Example 7
Source File: AbbrevDetection.java    From netbeans with Apache License 2.0 5 votes vote down vote up
public void caretUpdate(CaretEvent evt) {
    if (evt.getDot() != evt.getMark()) {
        surroundsWithTimer.setInitialDelay(SURROUND_WITH_DELAY);
        surroundsWithTimer.restart();
    } else {
        surroundsWithTimer.stop();
        hideSurroundWithHint();
    }
}
 
Example 8
Source File: TokenMarker.java    From visualvm with GNU General Public License v2.0 5 votes vote down vote up
@Override
public void caretUpdate(CaretEvent e) {
    int pos = e.getDot();
    SyntaxDocument doc = ActionUtils.getSyntaxDocument(pane);
    Token token = doc.getTokenAt(pos);
    removeMarkers();
    if (token != null && tokenTypes.contains(token.type)) {
        addMarkers(token);
    }
}
 
Example 9
Source File: PairsMarker.java    From visualvm with GNU General Public License v2.0 5 votes vote down vote up
@Override
public void caretUpdate(CaretEvent e) {
    removeMarkers();
    int pos = e.getDot();
    SyntaxDocument doc = ActionUtils.getSyntaxDocument(pane);
    Token token = doc.getTokenAt(pos);
    if (token != null && token.pairValue != 0) {
        Markers.markToken(pane, token, marker);
        Token other = doc.getPairFor(token);
        if (other != null) {
            Markers.markToken(pane, other, marker);
        }
    }
}
 
Example 10
Source File: PairsMarker.java    From jpexs-decompiler with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void caretUpdate(CaretEvent e) {
    removeMarkers();
    int pos = e.getDot();
    SyntaxDocument doc = ActionUtils.getSyntaxDocument(pane);
    Token token = doc.getTokenAt(pos);
    if (token != null && token.pairValue != 0) {
        Markers.markToken(pane, token, marker);
        Token other = doc.getPairFor(token);
        if (other != null) {
            Markers.markToken(pane, other, marker);
        }
    }
}
 
Example 11
Source File: AutomaticTextField.java    From rapidminer-studio with GNU Affero General Public License v3.0 4 votes vote down vote up
@Override
public void caretUpdate(CaretEvent e) {
	this.caretPosition = e.getDot();
}
 
Example 12
Source File: CaretChangeHandler.java    From uima-uimaj with Apache License 2.0 4 votes vote down vote up
@Override
public void caretUpdate(CaretEvent ce) {
  final int dot = ce.getDot();
  final int mark = ce.getMark();
  this.main.setCaretStatus(dot, mark);
}