write Area Swing StyledDocument - Java javax.swing.text

Java examples for javax.swing.text:StyledDocument

Description

write Area Swing StyledDocument

Demo Code


//package com.java2s;
import javax.swing.text.*;

public class Main {
    static SimpleAttributeSet sas_bold = new SimpleAttributeSet();
    static SimpleAttributeSet sas_noBold = new SimpleAttributeSet();

    private static void writeArea(StyledDocument doc, String s, boolean bold) {

        try {//from   w  ww . j a va2 s . com
            if (bold) {
                doc.insertString(doc.getLength(), s, sas_bold);
            } else {
                doc.insertString(doc.getLength(), s, sas_noBold);
            }
        } catch (BadLocationException blex) {
        }
    }
}

Related Tutorials