Java Reference
In-Depth Information
Table 16-4. Key Constants for Storing AttributeSet Values
AttributeSet Key Constants
Value Type
Default Setting
CharacterConstants.ComponentAttribute
Component
null
CharacterConstants.Family
String
"Monospaced"
FontConstants.Family
String
"Monospaced"
CharacterConstants.Foreground
Color
Color.BLACK
ColorConstants.Foreground
Color
Color.BLACK
CharacterConstants.IconAttribute
Icon
null
CharacterConstants.Italic
Boolean
false
FontConstants.Italic
Boolean
false
CharacterConstants.Size
Integer
12
FontConstants.Size
Integer
12
CharacterConstants.StrikeThrough
Boolean
false
CharacterConstants.Subscript
Boolean
false
CharacterConstants.Superscript
Boolean
false
CharacterConstants.Underline
Boolean
false
ParagraphConstants.Alignment
Integer
ALIGN_LEFT
ParagraphConstants.FirstLineIndent
Float
0
ParagraphConstants.LeftIndent
Float
0
ParagraphConstants.LineSpacing
Float
0
ParagraphConstants.Orientation
unknown
unknown
ParagraphConstants.RightIndent
Float
0
ParagraphConstants.SpaceAbove
Float
0
ParagraphConstants.SpaceBelow
Float
0
ParagraphConstants.TabSet
TabSet
null
For example, to populate the StyledDocument for a JTextPane , after creating the
DefaultStyledDocument , you add content to it by calling the public void insertString(int
offset, String contents, AttributeSet attributes) method, which happens to throw a
BadLocationException . You can then change the attribute set and add more attributes. So, if
you wanted to create content that was both bold and italic, you would add two attributes to a
SimpleAttributeSet and insert the content into the document:
SimpleAttributeSet attributes = new SimpleAttributeSet();
attributes.addAttribute(StyleConstants.CharacterConstants.Bold, Boolean.TRUE);
attributes.addAttribute(StyleConstants.CharacterConstants.Italic, Boolean.TRUE);
 
Search WWH ::




Custom Search