Example usage for javax.swing.text StyleConstants setItalic

List of usage examples for javax.swing.text StyleConstants setItalic

Introduction

In this page you can find the example usage for javax.swing.text StyleConstants setItalic.

Prototype

public static void setItalic(MutableAttributeSet a, boolean b) 

Source Link

Document

Sets the italic attribute.

Usage

From source file:TextSamplerDemo.java

protected void addStylesToDocument(StyledDocument doc) {
    //Initialize some styles.
    Style def = StyleContext.getDefaultStyleContext().getStyle(StyleContext.DEFAULT_STYLE);

    Style regular = doc.addStyle("regular", def);
    StyleConstants.setFontFamily(def, "SansSerif");

    Style s = doc.addStyle("italic", regular);
    StyleConstants.setItalic(s, true);

    s = doc.addStyle("bold", regular);
    StyleConstants.setBold(s, true);

    s = doc.addStyle("small", regular);
    StyleConstants.setFontSize(s, 10);

    s = doc.addStyle("large", regular);
    StyleConstants.setFontSize(s, 16);

    s = doc.addStyle("icon", regular);
    StyleConstants.setAlignment(s, StyleConstants.ALIGN_CENTER);
    ImageIcon pigIcon = createImageIcon("images/Pig.gif", "a cute pig");
    if (pigIcon != null) {
        StyleConstants.setIcon(s, pigIcon);
    }/* w w w  .j  av  a2s  .  co  m*/

    s = doc.addStyle("button", regular);
    StyleConstants.setAlignment(s, StyleConstants.ALIGN_CENTER);
    ImageIcon soundIcon = createImageIcon("images/sound.gif", "sound icon");
    JButton button = new JButton();
    if (soundIcon != null) {
        button.setIcon(soundIcon);
    } else {
        button.setText("BEEP");
    }
    button.setCursor(Cursor.getDefaultCursor());
    button.setMargin(new Insets(0, 0, 0, 0));
    button.setActionCommand(buttonString);
    button.addActionListener(this);
    StyleConstants.setComponent(s, button);
}

From source file:TextComponentDemo.java

protected SimpleAttributeSet[] initAttributes(int length) {
    // Hard-code some attributes.
    SimpleAttributeSet[] attrs = new SimpleAttributeSet[length];

    attrs[0] = new SimpleAttributeSet();
    StyleConstants.setFontFamily(attrs[0], "SansSerif");
    StyleConstants.setFontSize(attrs[0], 16);

    attrs[1] = new SimpleAttributeSet(attrs[0]);
    StyleConstants.setBold(attrs[1], true);

    attrs[2] = new SimpleAttributeSet(attrs[0]);
    StyleConstants.setItalic(attrs[2], true);

    attrs[3] = new SimpleAttributeSet(attrs[0]);
    StyleConstants.setFontSize(attrs[3], 20);

    attrs[4] = new SimpleAttributeSet(attrs[0]);
    StyleConstants.setFontSize(attrs[4], 12);

    attrs[5] = new SimpleAttributeSet(attrs[0]);
    StyleConstants.setForeground(attrs[5], Color.red);

    return attrs;
}

From source file:TextComponentDemo.java

protected SimpleAttributeSet[] initAttributes(int length) {
    //Hard-code some attributes.
    SimpleAttributeSet[] attrs = new SimpleAttributeSet[length];

    attrs[0] = new SimpleAttributeSet();
    StyleConstants.setFontFamily(attrs[0], "SansSerif");
    StyleConstants.setFontSize(attrs[0], 16);

    attrs[1] = new SimpleAttributeSet(attrs[0]);
    StyleConstants.setBold(attrs[1], true);

    attrs[2] = new SimpleAttributeSet(attrs[0]);
    StyleConstants.setItalic(attrs[2], true);

    attrs[3] = new SimpleAttributeSet(attrs[0]);
    StyleConstants.setFontSize(attrs[3], 20);

    attrs[4] = new SimpleAttributeSet(attrs[0]);
    StyleConstants.setFontSize(attrs[4], 12);

    attrs[5] = new SimpleAttributeSet(attrs[0]);
    StyleConstants.setForeground(attrs[5], Color.red);

    return attrs;
}

From source file:gda.gui.BatonPanel.java

private JTextPane getLogPanel() {
    if (logPanel == null) {
        logPanel = new JTextPane();
        logPanel.setEditable(false);//from w  w w  .j a v  a2s  .c o  m
        StyledDocument doc = logPanel.getStyledDocument();

        Style def = StyleContext.getDefaultStyleContext().getStyle(StyleContext.DEFAULT_STYLE);

        Style regular = doc.addStyle("regular", def);
        StyleConstants.setFontFamily(def, "SansSerif");

        Style s = doc.addStyle("italic", regular);
        StyleConstants.setItalic(s, true);

        s = doc.addStyle("bold", regular);
        StyleConstants.setBold(s, true);
    }
    return logPanel;
}

From source file:net.team2xh.crt.gui.editor.EditorTextPane.java

private void initAttributeSets() {
    Theme theme = Theme.getTheme();/* w w w.  j  a  v a  2  s .  co m*/
    StyleConstants.setForeground(OPERATORS, theme.COLOR_10);
    StyleConstants.setForeground(NAME, theme.COLOR_11);
    StyleConstants.setItalic(NAME, true);
    StyleConstants.setForeground(NUMBER, theme.COLOR_09);
    StyleConstants.setForeground(COMMENT, theme.COLOR_16);
    StyleConstants.setForeground(BLOCK, theme.COLOR_06);
    StyleConstants.setItalic(BLOCK, true);
    StyleConstants.setForeground(NORMAL, theme.COLOR_11);
    StyleConstants.setForeground(IDENTIFIER, theme.COLOR_11);
    StyleConstants.setForeground(TRANSFORM, theme.COLOR_08);
    StyleConstants.setForeground(STRING, theme.COLOR_12);
}

From source file:org.astrojournal.logging.JTextPaneAppender.java

/**
 * Add the graphical JTextPane to capture the logging information.
 * // w ww  .  jav a2  s  . c o m
 * @param textPane
 */
public static void addJTextPane(final JTextPane textPane) {
    // The application graphical output
    jTextPane = textPane;

    // Define JTextPane styles
    StyledDocument doc = jTextPane.getStyledDocument();
    styleRegular = doc.addStyle("regular", null);
    StyleConstants.setForeground(styleRegular, Color.BLACK);
    StyleConstants.setFontSize(styleRegular, 12);
    StyleConstants.setFontFamily(styleRegular, "Arial");

    styleBold = doc.addStyle("bold", styleRegular);
    StyleConstants.setBold(styleBold, true);

    styleItalic = doc.addStyle("italic", styleRegular);
    StyleConstants.setItalic(styleItalic, true);

    styleSmall = doc.addStyle("small", styleRegular);
    StyleConstants.setFontSize(styleSmall, 11);

    styleSmallItalic = doc.addStyle("smallItalic", styleSmall);
    StyleConstants.setItalic(styleSmallItalic, true);

    styleRed = doc.addStyle("red", styleBold);
    StyleConstants.setForeground(styleRed, Color.RED);

    styleBlue = doc.addStyle("blue", styleSmall);
    StyleConstants.setForeground(styleBlue, Color.BLUE);

    // Remove the Appender Console as the GUI is being initialised and
    // therefore having this information twice is not desirable.
    Logger logger = LogManager.getLogger("Console");
    org.apache.logging.log4j.core.Logger coreLogger = (org.apache.logging.log4j.core.Logger) logger;
    LoggerContext context = coreLogger.getContext();
    coreLogger.removeAppender(context.getConfiguration().getAppender("Console"));
}

From source file:org.quackbot.gui.GUIConsoleAppender.java

public void init() {
    //Init styles
    for (JTextPane curPane : ImmutableList.of(gui.BerrorLog, gui.CerrorLog)) {
        StyledDocument doc = curPane.getStyledDocument();
        doc.addStyle("Normal", null);
        StyleConstants.setForeground(doc.addStyle("Class", null), Color.blue);
        StyleConstants.setForeground(doc.addStyle("Error", null), Color.red);
        //BotSend gets a better shade of orange than Color.organ gives
        StyleConstants.setForeground(doc.addStyle("BotSend", null), new Color(255, 127, 0));
        //BotRecv gets a better shade of green than Color.green gives
        StyleConstants.setForeground(doc.addStyle("BotRecv", null), new Color(0, 159, 107));
        StyleConstants.setBold(doc.addStyle("Server", null), true);
        StyleConstants.setItalic(doc.addStyle("Thread", null), true);
        StyleConstants.setItalic(doc.addStyle("Level", null), true);
    }/*  w w  w .j a v  a 2s .com*/

    log.debug("Inited GUILogAppender, processing any saved messages");
    synchronized (initMessageQueue) {
        inited = true;
        while (!initMessageQueue.isEmpty())
            append(initMessageQueue.poll());
    }
}

From source file:org.smart.migrate.ui.ImportThread.java

private void addStylesToDocument(StyledDocument doc) {
    //Initialize some styles.
    Style def = StyleContext.getDefaultStyleContext().getStyle(StyleContext.DEFAULT_STYLE);

    Style regular = doc.addStyle("regular", def);
    StyleConstants.setFontFamily(def, "SansSerif");

    Style s = doc.addStyle("italic", regular);
    StyleConstants.setItalic(s, true);

    s = doc.addStyle("bold", regular);
    StyleConstants.setBold(s, true);

    s = doc.addStyle("small", regular);
    StyleConstants.setFontSize(s, 10);

    s = doc.addStyle("large", regular);
    StyleConstants.setFontSize(s, 16);

    s = doc.addStyle("icon", regular);
    StyleConstants.setAlignment(s, StyleConstants.ALIGN_CENTER);

    s = doc.addStyle("info", regular);
    StyleConstants.setForeground(s, Color.blue);

    s = doc.addStyle("error", regular);
    StyleConstants.setForeground(s, Color.red);

    s = doc.addStyle("warning", regular);
    StyleConstants.setForeground(s, Color.orange);

    s = doc.addStyle("gray", regular);
    StyleConstants.setForeground(s, Color.gray);

    s = doc.addStyle("success", regular);
    StyleConstants.setForeground(s, Color.green);
}

From source file:org.thelq.stackexchange.dbimport.gui.GUILogAppender.java

public void init() {
    //Configure logger
    loggerText = gui.getLoggerText();//from   ww  w. ja  v  a  2  s  .c o  m
    loggerStyle = loggerText.getStyledDocument();
    loggerStyle.addStyle("Normal", null);
    StyleConstants.setForeground(loggerStyle.addStyle("Class", null), Color.blue);
    StyleConstants.setForeground(loggerStyle.addStyle("Error", null), Color.red);
    StyleConstants.setItalic(loggerStyle.addStyle("Thread", null), true);
    StyleConstants.setItalic(loggerStyle.addStyle("Level", null), true);

    log.debug("Inited GUILogAppender, processing any saved messages");
    synchronized (initMessageQueue) {
        inited = true;
        while (!initMessageQueue.isEmpty())
            append(initMessageQueue.poll());
    }
}

From source file:org.zephyrsoft.sdb2.presenter.SongView.java

private Style addStyle(String styleName, boolean italic, boolean bold, String fontFamily, int fontSize) {
    Style style = document.addStyle(styleName, DEFAULT_STYLE);
    StyleConstants.setItalic(style, italic);
    StyleConstants.setBold(style, bold);
    StyleConstants.setFontFamily(style, fontFamily);
    StyleConstants.setFontSize(style, fontSize);
    return style;
}