• Post Reply Bookmark Topic Watch Topic
  • New Topic

Struck with Document Interface  RSS feed

 
Balasubramanian Chandrasekaran
Ranch Hand
Posts: 215
Firefox Browser Linux VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I need to use Rich Text Capabilities in my application.I came to know that this can be achieved by using Document Interface(StyledDocument,DefaultStyledDocument) in javax.swing.text Package. I am new to this Document Interface can you guys guide me in this matter.

If you can point me where can i get more details about this interface. Where can i get a beginning material in this topic.I Searched for this in Google and ended up with nothing.
 
Rob Spoor
Sheriff
Posts: 21050
85
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It's StyledDocument you want to work with.

This interface has methods called "setCharacterAttributes" and "setParagraphAttributes". With these method, you can set attributes for a specific range of text (to be honest, I don't know the difference between the two).

Such attributes include boldness, foreground colors, background colors, fonts, etc.

You can create attributes as follows:

Check out the other StyleConstants methods.

To switch bold etc off, you explicitly have to turn it off in the attribute set, then set it. If it isn't explicitly turned to off nothing will change.
 
Balasubramanian Chandrasekaran
Ranch Hand
Posts: 215
Firefox Browser Linux VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you Rob for the information you shared.

I will work it out and reply you back

 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!