textPane = new JTextPane();
styledDoc = textPane.getStyledDocument();
//..Regulat Text Style
Style def = StyleContext.getDefaultStyleContext().getStyle(StyleContext.DEFAULT_STYLE);
Style regular = styledDoc.addStyle("regular", def);
StyleConstants.setForeground(regular, Color.BLACK);
StyleConstants.setBackground(regular, Color.WHITE);
StyleConstants.setFontFamily(regular, "Courier New");
StyleConstants.setFontSize(regular,12);
StyleConstants.setLineSpacing(regular, 0.25f);
//..Keyword1 Text Style
Style keyword1Style = styledDoc.addStyle("keyword1Style", regular);
StyleConstants.setForeground(keyword1Style, Color.RED);
StyleConstants.setBackground(keyword1Style, Color.YELLOW);
StyleConstants.setFontFamily(keyword1Style, "Courier New");
StyleConstants.setFontSize(keyword1Style,12);
StyleConstants.setBold(keyword1Style,false);
StyleConstants.setLineSpacing(keyword1Style, 0.25f);
//..Keyword2 Text Style
Style keyword2Style = styledDoc.addStyle("keyword2Style", regular);
StyleConstants.setForeground(keyword2Style, Color.GREEN);
StyleConstants.setBackground(keyword2Style, Color.YELLOW);
StyleConstants.setFontFamily(keyword2Style, "Courier New");
StyleConstants.setFontSize(keyword2Style,12);
StyleConstants.setBold(keyword2Style,false);