1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28
|
private void initDocument() {
// Initialize some styles.
Style def = StyleContext.getDefaultStyleContext().getStyle(
StyleContext.DEFAULT_STYLE);
Style regular = doc.addStyle("normal", def);
StyleConstants.setFontFamily(def, "Courier New");
Style s = doc.addStyle("--", regular);// error
StyleConstants.setForeground(s, new Color(250, 0, 0));
s = doc.addStyle("##", regular);// break
StyleConstants.setForeground(s, new Color(0, 64, 128));
s = doc.addStyle("**", regular);// conversion
StyleConstants.setForeground(s, new Color(120, 64, 0));
s = doc.addStyle("$$", regular);// parsing
StyleConstants.setForeground(s, new Color(0, 128, 128));
s = doc.addStyle("++", regular);// ok
StyleConstants.setForeground(s, new Color(0, 128, 0));
s = doc.addStyle("info", regular);// information
StyleConstants.setAlignment(s, StyleConstants.ALIGN_CENTER);
StyleConstants.setForeground(s, new Color(170, 55, 0));
} |
Partager