I am looking into syntax highlighting and I came across this tool XML Text Editor. The highlighting job is done in the drawUnselectedText of the PlainView component. I am trying to understand how it works, the API really doesn't give me much and I have not been able to find any useful resources that explain the specific purpose of this method. To understand this i downloaded the code and put some println statements to see when it is exactly executed and the parameters passed. But i still haven't really gotten a grasp on it. For one thing, it seems that this method is called numerous times, not just when something is typed into the text area.