![]() |
The Java Developers Almanac 1.4 |
|
e1014. Determining If a Style Attribute Applies to a Character or the ParagraphAll style attributes as defined inStyleConstants are either
character- or paragraph-based attributes. See also
e1010 Listing the Attributes in a Style.
boolean b;
// Check if character-based attribute
b = StyleConstants.Italic instanceof AttributeSet.CharacterAttribute; // true
b = StyleConstants.LineSpacing instanceof AttributeSet.CharacterAttribute; // false
// Check if paragraph-based attribute
b = StyleConstants.LineSpacing instanceof AttributeSet.ParagraphAttribute; // true
b = StyleConstants.Italic instanceof AttributeSet.ParagraphAttribute; // false
It is also possible to determine if the attribute is a color or a
font-related attribute.
// Check if color-based attribute
b = StyleConstants.Foreground instanceof AttributeSet.ColorAttribute; // true
b = StyleConstants.Italic instanceof AttributeSet.ColorAttribute; // false
// Check if font-based attribute
b = StyleConstants.Italic instanceof AttributeSet.FontAttribute; // true
b = StyleConstants.Foreground instanceof AttributeSet.FontAttribute; // false
e1007. Setting the Font and Color of Text in a JTextPane Using Styles e1008. Sharing Styles Between JTextPanes e1009. Listing the Styles Associated with a JTextPane e1010. Listing the Attributes in a Style e1011. Using a Popup to Apply Styles to a JTextPane e1012. Retaining the Logical Style When Setting a New Paragraph Style e1013. Automatically Updating Styled Text When a Style Is Updated
© 2002 Addison-Wesley. |