private Highlight[] getHighlights(String text, Address minAddr, List<MemoryMatch> results) {

		Highlight[] highlights = new Highlight[results.size()];
		int selectedMatchIndex = -1;

		for (int i = 0; i < highlights.length; i++) {
			MemoryMatch match = results.get(i);
			Color highlightColor = SearchConstants.SEARCH_HIGHLIGHT_COLOR;
			if (match == selectedMatch) {
				selectedMatchIndex = i;
				highlightColor = SearchConstants.SEARCH_HIGHLIGHT_CURRENT_ADDR_COLOR;
			}
			highlights[i] = createHighlight(match, minAddr, text, highlightColor);
		}

		// move the selected match to the end so that it gets painted last and doesn't get 
		// painted over by the non-active highlights
		if (selectedMatchIndex >= 0) {
			ArrayUtils.swap(highlights, selectedMatchIndex, highlights.length - 1);
		}

		return highlights;
	}
Listing highlight provider to highlight memory search results.
Ghidra/Features/Base/src/main/java/ghidra/features/base/memsearch/gui/MemoryMatchHighlighter.java