Java Swing Text Style getBooleanValue(Element element, Object constant)

Here you can find the source of getBooleanValue(Element element, Object constant)

Description

Checks whether an Element has a boolean property

License

Open Source License

Parameter

Parameter Description
element RTF-Element
constant Constant (e.g StyleConstants.Bold)

Return

true if it applies, false otherwise

Declaration

public static Boolean getBooleanValue(Element element, Object constant) 

Method Source Code

//package com.java2s;
//License from project: Open Source License 

import javax.swing.text.AttributeSet;
import javax.swing.text.Element;

public class Main {
    /**/*from  w  w w  . jav  a 2  s.com*/
     * Checks whether an Element has a boolean property
     * 
     * @todo Check if constant is of type boolean
     * @param element
     *            RTF-Element
     * @param constant
     *            Constant (e.g StyleConstants.Bold)
     * @return true if it applies, false otherwise
     * 
     */
    public static Boolean getBooleanValue(Element element, Object constant) {
        AttributeSet attributes = element.getAttributes();

        return (attributes.getAttribute(constant) != null
                && ((Boolean) attributes.getAttribute(constant)).booleanValue());

    }
}

Related

  1. createStyle(String logicalName)
  2. getIntegerValue(Element element, Object constant)
  3. getNextVisualPosition(final View v, final int pos, final Position.Bias b0, final int direction, final Position.Bias[] biasRet)
  4. hasDifferentCharacterAttributes(AttributeSet style, AttributeSet base)
  5. isCentered(AttributeSet attributes)