Java Change Color of Element on JTextPane using StyledDocument
问题 this is kinda overkill for me.. I am using a JTextPane for a chat, I have colors there.. What I want is, with reference to a element changing the color of it.. I am using StyledDocument, I have no clue how to do this.. Thanks in advance ;) 回答1: Use setCharacterAttributes(). Define desired color in a SimpleAttributeSet using StyleConstants.setBackground()/setForeground(). Use Element's start and end offsets for the offset and length. If the last attribute is false only thouse attributes of