JTextPane (reading char and its attributes)
I am trying to write a simple editor, where a person could write his text (in different size and color etc.) and than i need to turn this text to html code.
So the way that i determen the shape of the text in JTextPane is:
And now, when the text is done, i have to convert this to a simple html code. My idea of doing that is, to go trough the text (TextPane.setCaretPosition(x); TextPane.moveCaretPosition(x+1);).
So so far so good...but now i have to get the attributes of this character (and only of this character)!
pane.getCharacterAttributes().getAttributeCount()...this does this:
0001111 (number of attributes)
so on the text later, the previus attibute of the letter is still being counted in, but it should not be so (as the getCharacterAttributes() uses the caret to find that out).
Is the whole approach wrong? Or how to fix this?