Determine if the attribute is a color or a font-related attribute.
import javax.swing.text.AttributeSet; import javax.swing.text.StyleConstants; public class Main { public static void main(String[] argv) { // Check if color-based attribute boolean b = StyleConstants.Foreground instanceof AttributeSet.ColorAttribute; b = StyleConstants.Italic instanceof AttributeSet.ColorAttribute; // Check if font-based attribute b = StyleConstants.Italic instanceof AttributeSet.FontAttribute; b = StyleConstants.Foreground instanceof AttributeSet.FontAttribute; } }