Here you can find the source of highlighterIsNext(JTextComponent textComponent, boolean forwards, Highlighter.Highlight highlight)
private static boolean highlighterIsNext(JTextComponent textComponent, boolean forwards, Highlighter.Highlight highlight)
//package com.java2s; //License from project: Open Source License import javax.swing.text.*; public class Main { private static boolean highlighterIsNext(JTextComponent textComponent, boolean forwards, Highlighter.Highlight highlight) { final int minOffset = Math.min(highlight.getStartOffset(), highlight.getEndOffset()); final int maxOffset = Math.max(highlight.getStartOffset(), highlight.getEndOffset()); if (forwards) { return minOffset > textComponent.getSelectionEnd(); } else {// ww w .j a v a 2 s. c om return maxOffset < textComponent.getSelectionStart(); } } }