Example usage for javax.swing.text StyledEditorKit getInputAttributes

List of usage examples for javax.swing.text StyledEditorKit getInputAttributes

Introduction

In this page you can find the example usage for javax.swing.text StyledEditorKit getInputAttributes.

Prototype

public MutableAttributeSet getInputAttributes() 

Source Link

Document

Gets the input attributes for the pane.

Usage

From source file:MainClass.java

public void actionPerformed(ActionEvent e) {
    JEditorPane editor = getEditor(e);
    if (editor != null) {
        StyledEditorKit kit = getStyledEditorKit(editor);
        MutableAttributeSet attr = kit.getInputAttributes();
        boolean italic = (StyleConstants.isItalic(attr)) ? false : true;
        SimpleAttributeSet sas = new SimpleAttributeSet();
        StyleConstants.setItalic(sas, italic);
        setCharacterAttributes(editor, sas, false);
    }//from  www.j av a  2  s. c om
}

From source file:MainClass.java

public void actionPerformed(ActionEvent e) {
    JEditorPane editor = getEditor(e);
    if (editor != null) {
        StyledEditorKit kit = getStyledEditorKit(editor);
        MutableAttributeSet attr = kit.getInputAttributes();
        boolean bold = (StyleConstants.isBold(attr)) ? false : true;
        SimpleAttributeSet sas = new SimpleAttributeSet();
        StyleConstants.setBold(sas, bold);
        setCharacterAttributes(editor, sas, false);

    }// w  ww .j  a  v  a  2s.  co m
}

From source file:net.java.sip.communicator.impl.gui.main.chat.ChatWritePanel.java

/**
 * Enables the bold style//w  ww  .j a  v a 2 s  .  c o  m
 * @param b TRUE enable - FALSE disable
 */
public void setBoldStyleEnable(boolean b) {
    StyledEditorKit editorKit = (StyledEditorKit) editorPane.getEditorKit();
    MutableAttributeSet attr = editorKit.getInputAttributes();

    if (b && !StyleConstants.isBold(attr)) {
        setStyleConstant(new HTMLEditorKit.BoldAction(), StyleConstants.Bold);
    }
}

From source file:net.java.sip.communicator.impl.gui.main.chat.ChatWritePanel.java

/**
 * Enables the italic style//  w ww  . j  a  v a 2s  .  c o m
 * @param b TRUE enable - FALSE disable
 */
public void setItalicStyleEnable(boolean b) {
    StyledEditorKit editorKit = (StyledEditorKit) editorPane.getEditorKit();
    MutableAttributeSet attr = editorKit.getInputAttributes();

    if (b && !StyleConstants.isItalic(attr)) {
        setStyleConstant(new HTMLEditorKit.ItalicAction(), StyleConstants.Italic);
    }
}

From source file:net.java.sip.communicator.impl.gui.main.chat.ChatWritePanel.java

/**
 * Enables the underline style//from   w w w  .  j a  va  2  s .  c  o  m
 * @param b TRUE enable - FALSE disable
 */
public void setUnderlineStyleEnable(boolean b) {
    StyledEditorKit editorKit = (StyledEditorKit) editorPane.getEditorKit();
    MutableAttributeSet attr = editorKit.getInputAttributes();

    if (b && !StyleConstants.isUnderline(attr)) {
        setStyleConstant(new HTMLEditorKit.UnderlineAction(), StyleConstants.Underline);
    }
}