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

The following examples show how to use javax.swing.event.CaretEvent#getDot() . These examples are extracted from open source projects. 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 want to check out the right sidebar which shows the related API usage.
Example 1
@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
@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 Project: netbeans   File: POMModelPanel.java    License: 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 Project: netbeans   File: ComponentPeer.java    License: 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
public void caretUpdate (CaretEvent e) {
    int position = e.getDot ();
    try {
        selectPath (position);
    } catch (ConcurrentModificationException ex) {
    }
}
 
Example 6
Source Project: netbeans   File: MarkOccurrences.java    License: 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 Project: netbeans   File: AbbrevDetection.java    License: 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
@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
@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
@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
@Override
public void caretUpdate(CaretEvent e) {
	this.caretPosition = e.getDot();
}
 
Example 12
Source Project: uima-uimaj   File: CaretChangeHandler.java    License: 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);
}