File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Getting a character's colour from a document

 
Clive Mercer
Greenhorn
Posts: 10
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi

Can someone please show me how to find out the colour of a character in a StyledDocument?

For example, I have a JTextPane and I wish to know if a certain character's foreground is Green?

Thanks
 
Rob Spoor
Sheriff
Pie
Posts: 20388
46
Chrome Eclipse IDE Java Windows
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Did you check out the Javadoc page of StyledDocument? I think not, or you would have found the getCharacterElement(int pos) method. That returns an Element that represent the single character. From the Element you can then retrieve the AttributeSet using getAttributes().
 
Clive Mercer
Greenhorn
Posts: 10
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Funnily enough I just did exactly what you said, then I couldn't post on the forum because it was under maintenance.

Still, thank you for the very fast response!
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic