Java Color Value getColorValue(Element element, Object constant)

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

Description

Gets a integer value of an attribute (e.g.

License

Open Source License

Parameter

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

Return

Value, null otherwise

Declaration

public static Color getColorValue(Element element, Object constant) 

Method Source Code


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

import java.awt.Color;
import javax.swing.text.AttributeSet;
import javax.swing.text.Element;

public class Main {
    /**// www  . j av  a 2 s  . com
     * Gets a integer value of an attribute (e.g. StyleConstants.FontFamily)
     * 
     * @param element
     *            RTF-Element
     * @param constant
     *            Constant (e.g StyleConstants.Foreground)
     * 
     * @return Value, null otherwise
     */
    public static Color getColorValue(Element element, Object constant) {
        AttributeSet attributes = element.getAttributes();

        Object obj = attributes.getAttribute(constant);
        if (obj == null)
            return null;

        return (Color) obj;
    }
}

Related

  1. getColorBackground()
  2. getColorChooser()
  3. getColorForeground()
  4. getColorLabels(Object obj)
  5. getColorTercio(Color a, Color b)
  6. getDefaultBackgroundColor()
  7. getDefaultBackgroundColor(Color color)
  8. getDerivedColor(Color color, float ratio)
  9. getDisabledForeground(Color c)