Example usage for java.awt.font TextAttribute UNDERLINE

List of usage examples for java.awt.font TextAttribute UNDERLINE

Introduction

In this page you can find the example usage for java.awt.font TextAttribute UNDERLINE.

Prototype

TextAttribute UNDERLINE

To view the source code for java.awt.font TextAttribute UNDERLINE.

Click Source Link

Document

Attribute key for underline.

Usage

From source file:VASSAL.tools.imports.adc2.MapBoard.java

/**
 * Get a font based on size and font index. If this font has not already been created, then it will be generated.
 * Can be reused later if the same font was already created.
 *
 * @param size Font size./*w w  w.  ja  v a  2  s .  c o  m*/
 * @param font Font index. See MapBoard.java for format.
 */

/* Binary format for fonts:
 *
 *             00000000
 *                 ||||_ Font name index (between 1 and 9).
 *                |_____ Bold flag.
 *               |______ Italics flag.
 *              |_______ Underline flag.
 */
protected static Font getDefaultFont(int size, int font) {
    final Integer key = Integer.valueOf((size << 8) + font);
    Font f = defaultFonts.get(key);
    if (f == null) {
        int fontIndex = font & 0xf;
        assert (fontIndex >= 1 && fontIndex <= 9);
        boolean isBold = (font & 0x0010) > 0;
        boolean isItalic = (font & 0x0020) > 0;
        boolean isUnderline = (font & 0x0040) > 0;
        String fontName = defaultFontNames[fontIndex - 1];
        int fontStyle = Font.PLAIN;
        if (isItalic)
            fontStyle |= Font.ITALIC;
        if (isBold)
            fontStyle |= Font.BOLD;
        f = new Font(fontName, fontStyle, size);
        if (isUnderline) {
            // TODO: why doesn't underlining doesn't work? Why why why?
            Hashtable<TextAttribute, Object> hash = new Hashtable<TextAttribute, Object>();
            hash.put(TextAttribute.UNDERLINE, TextAttribute.UNDERLINE_ON);
            f = f.deriveFont(hash);
        }
        defaultFonts.put(key, f);
    }
    return f;
}

From source file:wsattacker.sso.openid.attacker.gui.MainGui.java

/**
 * Creates new form MainGui/*from   w ww .jav a  2  s. c  om*/
 */
public MainGui() {
    initComponents();

    analyzerIdpServerConfigurationGui.setIdp(IdpType.ANALYZER);
    analyzerIdpHtmlConfigurationGui.setIdp(IdpType.ANALYZER);
    analyzerIdpXrdsConfigurationGui.setIdp(IdpType.ANALYZER);
    analyzerIdpValidDataGui.setIdp(IdpType.ANALYZER);
    analyzerIdpAttackDataGui.setIdp(IdpType.ANALYZER);
    //analyzerIdpAttackOverviewGui.setIdp(IdpType.ANALYZER);

    Map<TextAttribute, Integer> fontAttributes = new HashMap<>();
    fontAttributes.put(TextAttribute.UNDERLINE, TextAttribute.LIGATURES_ON);
    boldUnderline = new Font(Font.SANS_SERIF, Font.BOLD, defaultFont.getSize()).deriveFont(fontAttributes);

    splitPane.setRightComponent(attackerIdpServerConfigurationGui);
    attackerIdpServerConfigurationButton.setFont(boldUnderline);

    // ========== Attacker IdP Task Pane ==========
    removeBackgroundFromButton(attackerIdpServerConfigurationButton);
    attackerIdpServerConfigurationButton.addActionListener(this);
    attackerIdpTaskPane.add(attackerIdpServerConfigurationButton);

    removeBackgroundFromButton(attackerIdpHtmlDiscoveryButton);
    attackerIdpHtmlDiscoveryButton.addActionListener(this);
    attackerIdpTaskPane.add(attackerIdpHtmlDiscoveryButton);

    removeBackgroundFromButton(attackerIdpXrdsDiscoveryButton);
    attackerIdpXrdsDiscoveryButton.addActionListener(this);
    attackerIdpTaskPane.add(attackerIdpXrdsDiscoveryButton);

    removeBackgroundFromButton(attackerIdpValidDataButton);
    attackerIdpValidDataButton.addActionListener(this);
    attackerIdpTaskPane.add(attackerIdpValidDataButton);

    removeBackgroundFromButton(attackerIdpAttackDataButton);
    attackerIdpAttackDataButton.addActionListener(this);
    attackerIdpTaskPane.add(attackerIdpAttackDataButton);

    removeBackgroundFromButton(attackerIdpAttackOverviewButton);
    attackerIdpAttackOverviewButton.addActionListener(this);
    attackerIdpTaskPane.add(attackerIdpAttackOverviewButton);

    // ========== Analyzer IdP Task Pane ==========
    removeBackgroundFromButton(analyzerIdpServerConfigurationButton);
    analyzerIdpServerConfigurationButton.addActionListener(this);
    analyzerIdpTaskPane.add(analyzerIdpServerConfigurationButton);

    removeBackgroundFromButton(analyzerIdpHtmlDiscoveryButton);
    analyzerIdpHtmlDiscoveryButton.addActionListener(this);
    analyzerIdpTaskPane.add(analyzerIdpHtmlDiscoveryButton);

    removeBackgroundFromButton(analyzerIdpXrdsDiscoveryButton);
    analyzerIdpXrdsDiscoveryButton.addActionListener(this);
    analyzerIdpTaskPane.add(analyzerIdpXrdsDiscoveryButton);

    removeBackgroundFromButton(analyzerIdpValidDataButton);
    analyzerIdpValidDataButton.addActionListener(this);
    analyzerIdpTaskPane.add(analyzerIdpValidDataButton);

    removeBackgroundFromButton(analyzerIdpAttackDataButton);
    analyzerIdpAttackDataButton.addActionListener(this);
    analyzerIdpTaskPane.add(analyzerIdpAttackDataButton);
    analyzerIdpAttackDataButton.setEnabled(false); // disable

    removeBackgroundFromButton(analyzerIdpAttackOverviewButton);
    analyzerIdpAttackOverviewButton.addActionListener(this);
    analyzerIdpTaskPane.add(analyzerIdpAttackOverviewButton);

    // ========== Evaluation Task Pane ==========
    removeBackgroundFromButton(evaluationButton);
    evaluationButton.addActionListener(this);
    evaluationTaskPane.add(evaluationButton);

    removeBackgroundFromButton(reportButton);
    reportButton.addActionListener(this);
    evaluationTaskPane.add(reportButton);

    // ========== Log Task Pane ==========
    removeBackgroundFromButton(logButton);
    logButton.addActionListener(this);
    logTaskPane.add(logButton);
}