Code example for JTextComponent

Methods: getSelectionEndgetSelectionStartselect

0
	 */ 
	public boolean doFindNext(JTextComponent target) {
		if (getPattern() == null) { 
			return false; 
		} 
		SyntaxDocument sDoc = ActionUtils.getSyntaxDocument(target);
		if (sDoc == null) {
			return false; 
		} 
		int start = target.getSelectionEnd();
		if (target.getSelectionEnd() == target.getSelectionStart()) {
			// we must advance the position by one, otherwise we will find 
			// the same text again 
			start++;
		} 
		if (start >= sDoc.getLength()) {
			start = sDoc.getLength();
		} 
		Matcher matcher = sDoc.getMatcher(getPattern(), start);
		if (matcher != null && matcher.find()) {
			// since we used an offset in the matcher, the matcher location 
			// MUST be offset by that location 
			target.select(matcher.start() + start, matcher.end() + start);
			return true; 
		} else { 
			if (isWrap()) { 
				matcher = sDoc.getMatcher(getPattern());
				if (matcher != null && matcher.find()) {
					target.select(matcher.start(), matcher.end());
					return true; 
				} else { 
					return false; 
				} 
			} else { 
Experience pair programming with AI  Get Codota for Java