getSearchField().addFocusListener(this);
}
protected boolean changed(JComponent comp, String str, Position.Bias bias) {
JTextComponent textComp = (JTextComponent) comp;
int offset = bias == Position.Bias.Forward ? textComp.getCaretPosition()
: textComp.getCaret().getMark() - 1;
int index = getNextMatch(textComp, str, offset, bias);
if (index != -1) {
textComp.setSelectionStart(index);
textComp.setSelectionEnd(index + str.length());
return true;
} else {
offset = bias == null || bias == Position.Bias.Forward ? 0 : textComp
.getDocument().getLength();
index = getNextMatch(textComp, str, offset, bias);
if (index != -1) {
textComp.select(index, index + str.length());
return true;
} else {
return false;
}
}