| |
14. 39. 2. Using StyleConstants class to simplify style sttribute settings |
|
- The StyleConstants class is full of helper methods to simplify setting attribute sets.
- Instead of calling the following to make the SimpleAttributeSet both bold and italic:
|
attributes.addAttribute(StyleConstants.CharacterConstants.Bold, Boolean.TRUE)
attributes.addAttribute(StyleConstants.CharacterConstants.Italic, Boolean.TRUE)
|
|
You could use the following: |
StyleConstants.setBold(attributes, true);
StyleConstants.setItalic(attributes, true);
|
|
|