code: void updateSearchResults(boolean selectFirstMatch)
      {
          clearHighlights();
          searchPanel.setMessage("");
          
          String query = searchPanel.getQuery();
  
          if (query.isEmpty())
          {
              handleMatch(null);
              return;
          }
          
          String text = getDocumentText();
          boolean ignoreCase = !searchPanel.isCaseSensitive();
          List<Point> appearances = 
              JTextComponents.find(text, query, ignoreCase);
          addHighlights(appearances, highlightColor);
  
          int caretPosition = textComponent.getCaretPosition();
          Point match = JTextComponents.findNext(
              text, query, caretPosition, ignoreCase);
          if (match == null)
          {
              match = JTextComponents.findNext(
                  text, query, 0, ignoreCase);
          }
          if (selectFirstMatch)
          {
              handleMatch(match);
          }
          else
          {
              handleMatch(null);
          }
  
          if (appearances.isEmpty())
          {
              searchPanel.setMessage("Not found");
          }
          else
          {
              searchPanel.setMessage(
                  "Found " + appearances.size() + " times");
          }
      }
docs: Update the search results (highlighting) when the query in the
  search panel changed
  
  @param selectFirstMatch Whether the first match should be selected