Results 1 to 1 of 1
- 07-19-2008, 08:09 PM #1
Member
- Join Date
- Jul 2008
- Posts
- 1
- Rep Power
- 0
JTextPane (reading char and its attributes)
Hellow,
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:
StyleConstants.setBold(set, false);
pane.setCharacterAttributes(set, false);
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:
Example text:
ABCDEFG..
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?
Thanks!
Similar Threads
-
JTextPane with servlets
By kinabaloo in forum Advanced JavaReplies: 2Last Post: 07-11-2008, 06:32 AM -
JTextPane Styles Example
By Java Tip in forum javax.swingReplies: 0Last Post: 06-27-2008, 07:48 PM -
Reading Char without needing to press enter
By x0psci in forum New To JavaReplies: 0Last Post: 11-23-2007, 04:28 PM -
how to insert tables into JTextPane
By osval in forum AWT / SwingReplies: 1Last Post: 07-29-2007, 09:11 AM -
Transparent JTextPane
By Ada in forum AWT / SwingReplies: 1Last Post: 05-31-2007, 09:50 PM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks