private void changeStyleProgrammatically() { // Set the font for all token types. setFont(textArea, new Font("Courier New", Font.PLAIN, 12)); // Change a few things here and there. SyntaxScheme scheme = textArea.getSyntaxScheme(); scheme.getStyle(Token.RESERVED_WORD).background = Color.white; scheme.getStyle(Token.RESERVED_WORD).foreground = Color.MAGENTA.darker().darker(); scheme.getStyle(Token.DATA_TYPE).foreground = Color.blue; scheme.getStyle(Token.LITERAL_STRING_DOUBLE_QUOTE).underline = true; scheme.getStyle(Token.LITERAL_NUMBER_HEXADECIMAL).underline = true; scheme.getStyle(Token.LITERAL_NUMBER_HEXADECIMAL).background = Color.pink; scheme.getStyle(Token.COMMENT_EOL).font = new Font("Georgia", Font.ITALIC, 10); textArea.revalidate(); }