Java 8 Caret - top ranked examples from Open Source projects

These code examples were ranked by Codota’s semantic indexing as the best open source examples for Java 8 Caret class.

This code example shows how to use the following methods:getDot, getMark, setDot
	 * @return The new dot and mark position. 
	 */ 
	protected static int makeMarkAndDotEqual(JTextArea textArea,
										boolean forward) {
		Caret c = textArea.getCaret();
		int val = forward ? Math.min(c.getDot(), c.getMark()) :
						Math.max(c.getDot(), c.getMark());
		c.setDot(val);
		return val;
	} 
 
 
	/** 
	 * Finds the next instance of the regular expression specified from 
	 * the caret position.  If a match is found, it is replaced with 
	 * the specified replacement string. 
	 * 
	 * @param textArea The text area in which to search. 
	 * @param toFind The regular expression to search for. 
	 * @param replaceWith The string to replace the found regex with. 
5
CodeRank
Connect your IDE to all the code out there  Get Codota for Java
This code example shows how to use the following methods:getDot, getMark
	 */ 
	public void actionPerformed(ActionEvent e) {
 
		// Don't do anything if they are selecting text. 
		Caret c = textArea.getCaret();
		if (c.getDot()!=c.getMark()) {
			return; 
		} 
 
		RSyntaxDocument doc = (RSyntaxDocument)textArea.getDocument();
		OccurrenceMarker occurrenceMarker = doc.getOccurrenceMarker();
		boolean occurrencesChanged = false;
 
		if (occurrenceMarker!=null) {
 
			doc.readLock();
			try { 
 
				Token t = occurrenceMarker.getTokenToMark(textArea);
 
5
CodeRank
Connect your IDE to all the code out there  Get Codota for Java
This code example shows how to use the following methods:setBlinkRate
		Caret caret = comp.getCaret();
		if (caret instanceof UIResource) {
			Object o = style.get(ctx, prefix + ".caretBlinkRate");
			if (o != null && o instanceof Integer) {
				Integer rate = (Integer) o;
				caret.setBlinkRate(rate.intValue());
			} 
		} 
	} 
} 
4
CodeRank
Connect your IDE to all the code out there  Get Codota for Java
This code example shows how to use the following methods:getDot
    } 
 
    @Override 
    protected ParseContext createParseContext(VersionedDocument versionedDocument, JTextComponent editor) {
        Caret caret = editor.getCaret();
        int offset = caret.getDot();
 
        SnapshotPosition position = new SnapshotPosition(versionedDocument.getCurrentSnapshot(), offset);
        return new ParseContext(getClass(), position, editor);
    } 
 
    private class CaretListenerImpl implements CaretListener {
 
        @Override 
        public void caretUpdate(CaretEvent e) {
            if (!hasAssociatedDataDefinitions(CursorSensitiveParserTaskScheduler.this.getClass(), NbEditorUtilities.getMimeType(getCurrentDocument()))) {
                return; 
            } 
 
            VersionedDocument document = getVersionedDocument();
3
CodeRank
Connect your IDE to all the code out there  Get Codota for Java
See Code Examples for Java 8 Caret Methods: