I am using DefaultStyledDocument class for a small application which allows users to edit a text file. Now the problem I am facing is, if the user types a particular word, say, "Internet", i want to display it using red color.
I added a document listener to listen to the document events but found implementations of the DocumentListener may not mutate the source of the event (i.e. the associated Document) in the documentation of DocumentListener.
How do I go about changing the color of the typed text?