Hello,
I found a similar lack of information, if you are trying to make a standalone platform application, in the end, this is how I did it in my application, yes, it can be a reinvention of the wheel .. but since I could not find the wheel in the first place, it can also create one.
I took information on how to create a set of java editors here: http://java.sun.com/products/jfc/tsc/articles/text/editor_kit/index.html
A small package with the necessary files was built and pulled it into my platform application under one of the modules. You will need tools.jar, where all these bits of the Scanner are hidden, it lives under the / lib JDK installation folder - you have to wrap this.
Then I used an example in a test program to figure out how to set styles - I like full control over the marker color.
Shamelessly copied from the included JavaKitTest ..
JavaContext styles = kit.getStylePreferences(); Style s; //Make Comment lurid green s = styles.getStyleForScanValue(Token.COMMENT.getScanValue()); StyleConstants.setForeground(s, new Color(102, 153, 153)); //Make String err.. wotever color that is.. s = styles.getStyleForScanValue(Token.STRINGVAL.getScanValue()); StyleConstants.setForeground(s, new Color(102, 153, 102)); //Make NEW nice n red s = styles.getStyleForScanValue(Token.NEW.getScanValue()); StyleConstants.setForeground(s, new Color(102, 10, 10)); //Do some other scan codes for keywords Color keyword = new Color(102, 102, 255); for (int code = 70; code <= 130; code++) { s = styles.getStyleForScanValue(code); if (s != null) { StyleConstants.setForeground(s, keyword); } }
It's just a java scanner, of course, with this example you can play with grammar and tokens and come up with your own rules, I think there are tutorials on all of this.
Hope this helps a bit.