This is how I was planning to do it I) In the plaindocument or abstractdocument fireinsertupdated(parameters) 1) find the element with the given offset 2) get the element attributes(element.getAttributes) 3) lex as we were doing in the plain view - add any token found in a token list and any uncomplete token must be recorded to set the lexer state 4) add a token list attribute to the element (attributet.addAttribute("tokenList", tokenList); 5) check for the amount of lines to lex according to an unmatched or incompleted token back and fourth fireremoveupdated(parameters) same as fireinsertupdated II) in the plainview in the drawline method find the element we are drawing get the tokenlist attributes from the element iterate through the tokens and paint the text according to the token identifier