| Author |
Saving with JTextPane & Attributes handling
|
john price
Ranch Hand
Joined: Feb 24, 2011
Posts: 495
|
|
This all compiles and runs fine.
Problems: Saving and Attributes handling
Problem in Detail: Saving: JTextPane saves data to a test file ("testfile.txt"). Doesn't information such as italics, bold, and size.
Problem in Detail: Attributes handling:
When you click to another area in the JTextPane (called "area"), the buttons are off. When you click one of the Attributes buttons while not at the end, it takes the attributes from the end and places them in the spot where you are typing.
What am I doing wrong and how do I fix them?
Thanks,
John Price aka cc11rocks
EDIT: Should I use a caret listener to fix the attributes problem?
|
“Don’t worry if it doesn’t work right. If everything did, you’d be out of a job.” (Mosher's Law of Software Engineering)
“If debugging is the process of removing bugs, then programming must be the process of putting them in.” (Edsger Dijkstra)
|
 |
Paul Clapham
Bartender
Joined: Oct 14, 2005
Posts: 16483
|
|
The API documentation for the "write" method of JTextPane says:
Stores the contents of the model into the given stream. By default this will store the model as plain text.
So you can't use that. You're going to have to serialize the Document which underlies the text component yourself. I don't know if there's a standard way to do that, but when I had to do it I serialized it as XML (I made up my own XML format for that).
|
 |
john price
Ranch Hand
Joined: Feb 24, 2011
Posts: 495
|
|
Okay, thanks for the saving.
Do you have any response for the attributes handling problem?
Thanks,
John Price aka cc11rocks
|
 |
john price
Ranch Hand
Joined: Feb 24, 2011
Posts: 495
|
|
This isn't working for some reason.
cc11rocks aka John Price
|
 |
 |
|
|
subject: Saving with JTextPane & Attributes handling
|
|
|