List of usage examples for javax.swing.text StyleConstants setBold
public static void setBold(MutableAttributeSet a, boolean b)
From source file:uk.ac.kcl.texthunter.core.AnnotationEditor.java
private void updateInfoTextPane(String newText) { StyledDocument doc;/*from w w w .ja v a 2 s . com*/ doc = infoTextPane.getStyledDocument(); // Define a keyword attribute SimpleAttributeSet newString = new SimpleAttributeSet(); StyleConstants.setForeground(newString, Color.RED); StyleConstants.setBold(newString, true); SimpleAttributeSet oldString = new SimpleAttributeSet(); StyleConstants.setForeground(oldString, Color.BLACK); StyleConstants.setBold(oldString, false); // Add some text try { doc.setCharacterAttributes(0, doc.getLength(), oldString, true); doc.insertString(doc.getLength(), "\n" + newText, newString); } catch (Exception e) { System.out.println(e); } }