Inserting Styled Text in a Text Pane See the StyleConstants class for more attributes. try { JTextPane textPane = new JTextPane(); StyledDocument doc = (StyledDocument)textPane.getDocument(); Style style = doc.addStyle("StyleName", null); // Italic StyleConstants.setItalic(style, true); // Bold StyleConstants.setBold(style, true); // Font Family StyleConstants.setFontFamily(style, "SansSerif"); // Font Size StyleConstants.setFontSize(style, 30); // Background Color StyleConstants.setBackground(style, Color.blue); // Foreground Color StyleConstants.setForeground(style, Color.white); // Append to document. doc.insertString(doc.getLength(), "Some Text", style); } catch (BadLocationException e) { }