I've just had a quick go at implementing this with the Syntax Highlighting component from JEdit (I was bored at work). The component is in the public domain, so could be used pretty easily. I recommend you check it out -- I'll try to have more of a play over the weekend and report back how far I get!