Como destacar palavras-chave em java ao abrir um arquivo e enquanto o usuário está digitando

Por isso, estou tentando destacar as palavras-chave em java, armazenadas em um arquivo de texto, pois o usuário abre um arquivo .java ou grava no arquivo .java. Eu acho que sei como saber se o arquivo é do tipo certo. No entanto, não sei como alterar a cor de determinadas palavras-chave. Se alguém pudesse ajudar, seria ótimo, porque agora é bem confuso. Eu queria saber se eu poderia usar minha função de substituição de alguma forma. Eu tentei fazer isso com os poucos métodos que tenho, mas ainda não está claro. Eu removi a maioria dos métodos e ouvintes, apenas sei que eles estão lá, mas são mantidos afastados para facilitar a leitura.

import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
import javax.swing.event.DocumentListener;
import javax.swing.event.DocumentEvent;
import java.util.Scanner;
import java.io.*;
import javax.swing.text.BadLocationException;
import javax.swing.text.DefaultHighlighter;
import javax.swing.text.Highlighter;
import javax.swing.text.Highlighter.HighlightPainter;
import javax.swing.text.JTextComponent;
import java.net.URI;
import java.util.*;

public class MyTextEditor extends JFrame implements ActionListener
{
  private JPanel panel = new JPanel(new BorderLayout());
  private JTextArea textArea = new JTextArea(0,0);
  private static final Color TA_BKGRD_CL = Color.BLACK;
  private static final Color TA_FRGRD_CL = Color.GREEN;
  private static final Color TA_CARET_CL = Color.WHITE;

  private JScrollPane scrollPane;
  private MenuBar menuBar = new MenuBar();


 public MyTextEditor()
 {

  this.setSize(750,800);
  this.setTitle("Zenith");
  this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
  textArea.setFont(new Font("Consolas", Font.BOLD, 14));
  textArea.setForeground(TA_FRGRD_CL);
  textArea.setBackground(TA_BKGRD_CL);
  textArea.setCaretColor(TA_CARET_CL);
  scrollPane.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_ALWAYS);
  scrollPane.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_ALWAYS);
  scrollPane.setVisible(true);
  textArea.add(scrollPane,BorderLayout.EAST);
  final LineNumberingTextArea lineNTA = new LineNumberingTextArea(textArea);
  DocumentListener documentListen = new DocumentListener()
  {
     public void insertUpdate(DocumentEvent documentEvent)
     {
        lineNTA.updateLineNumbers();  
     }
     public void removeUpdate(DocumentEvent documentEvent)
     {
        lineNTA.updateLineNumbers();
     }
     public void changedUpdate(DocumentEvent documentEvent)
     {
        lineNTA.updateLineNumbers();
     }
  };
  textArea.getDocument().addDocumentListener(documentListen);
  // Line numbers
  lineNTA.setBackground(Color.BLACK);
  lineNTA.setForeground(Color.WHITE);
  lineNTA.setFont(new Font("Consolas", Font.BOLD, 13));
  lineNTA.setEditable(false);
  lineNTA.setVisible(true);
  textArea.add(lineNTA);
  scrollPane.setVisible(true);
  scrollPane.add(textArea);

  getContentPane().add(scrollPane);

 }


public void findKeyWords(String ext)
{
  ArrayList<String> wordsInTA = new ArrayList<String>();
  int index = 0;

  if(ext == "java")
  {
     for(String line : textArea.getText().split(" "))
     {
        wordsInTA.add(line);
        index++;
     }
     try
     {

      while(index>0)
      {
           String temp = wordsInTA.get(index);
           boolean isKeyWord = binarySearch(temp);
           if(isKeyWord)
           {
             //Code that has not yet been made
           } 
           index--;    
     }
   }
   catch(IOException ex)
     {
        ex.printStackTrace();
     }
  }

}
private ArrayList<String> loadJavaWords() throws FileNotFoundException
{
  ArrayList<String> javaWords = new ArrayList<String>();
  Scanner scan = new Scanner(new File("JavaKeyWords.txt"));
  while(scan.hasNext())
  {
     javaWords.add(scan.next());
  }
  scan.close();
  return javaWords;
}
private boolean binarySearch(String word) throws FileNotFoundException
{
  ArrayList<String> javaWords = loadJavaWords();
  int min = 0;
  int max = javaWords.size()-1;
  while(min <= max)
  {
     int index = (max + min)/2;
     String guess = javaWords.get(index);
     int result = word.compareTo(guess);
     if(result == 0)
     {
        return true;
     }
     else if(result > 0)
     {
        min = index +1;
     }
     else if(result < 0)
     {
        max = index -1;
     }
  }
  return false;
}

public void replace()
{
  String wordToSearch = JOptionPane.showInputDialog(null, "Word to replace:");
  String wordToReplace = JOptionPane.showInputDialog(null, "Replacement word:");

  int m;
  int total = 0;
  int wordLength = wordToSearch.length();
  for (String line : textArea.getText().split("\\n")) 
  {
     m = line.indexOf(wordToSearch);
     if(m == -1)
     {
        total += line.length() + 1; 
        continue;
     }

     String newLine = line.replaceAll(wordToSearch, wordToReplace);
     textArea.replaceRange(newLine, total, total + line.length());
     total += newLine.length() + 1;
  }
}

public static void main(String args[])
{
  MyTextEditor textEditor = new MyTextEditor();
  textEditor.setVisible(true);
}

}

questionAnswers(0)

yourAnswerToTheQuestion