How to change attributs of a piece of Document ?

Hello,

I have a JTextPane and a Document which has inherited of DefaultStyleDocument.

When the user has selected a piece of the text, I want to make him changes a few attributs

I looked at the sample TextComponentDemo, but all attributs are specified in menu items (so they are quite static).

In fact, users want to :

1. Select part of the text

2. Click on a menu item for example "Change Color" which invokes the JColorChooser Class

3. change the text after having selected a color.

More generally, this applies also to font name from the font family, font syle and font size.

I noticed that there is a class name AttributSet, but I don't know how to manipulate this set (especially where to find attribut names).

Thanks in advance for suggestions,examples, or pointers to good documentations

Gege

[886 byte] By [martinelligegea] at [2007-10-3 4:31:12]
# 1

> but all attributs are specified in menu items (so they are quite static).

Yes, but the Action is created using a color Object. So just create an action using the color selected from the JColorChooser and then invoke its actionPerformed() method:

Action foreground = new StyledEditorKit.ForegroundAction("", colorFromColorChooser);

foreground.actionPerformed(null);

camickra at 2007-7-14 22:34:35 > top of Java-index,Desktop,Core GUI APIs...
# 2
Thanks a lot, it works fine. It's exactly what I was looking for.
martinelligegea at 2007-7-14 22:34:35 > top of Java-index,Desktop,Core GUI APIs...