Creating Styled Text: Using a SimpleAttributeSet : SimpleAttributeSet « Swing « Java Tutorial






Key Constants for Storing AttributeSet Values

AttributeSet Key Constants            Value Type     Default Setting
                                      
CharacterConstants.Background         Color          Color.BLACK
                                      
ColorConstants.Background             Color          Color.BLACK
                                      
CharacterConstants.BidiLevel          Integer        0
                                      
CharacterConstants.Bold               Boolean        false
                                      
FontConstants.Bold                    Boolean        false

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








14.39.SimpleAttributeSet
14.39.1.Creating Styled Text: Using a SimpleAttributeSet
14.39.2.Using StyleConstants class to simplify style sttribute settings
14.39.3.Add colored text to the document
14.39.4.Use SimpleAttributeSet with JTextPane
14.39.5.Tests two attributed strings for equality.