I have an application with a JTextPane containing text mixed with
components. Specifically, there are JTextFields interspersed with the
text. The text is edited in the application, and the text fields are
added, removed, and moved as part of the editing process.
There is a problem: if there are JTextFields in the JTextPane, then
clicking near the end of the text does the Wrong Thing. If you click
near the end of the text, the cursor is placed way at the end of the
text (after the last character) instead of properly placed where you
click. "Near" in this case seems to correspond to the width of the
JTextFields. If there are no text fields, there is no problem.
So, say I have a string of only text in the text pane. Clicking
anywhere properly places the cursor where I click. But if I add a text
field, then clicking near the end of the text, where "near" means
"within the width of a text field", then the cursor improperly appears
after the last text character.
My diagnosis (corrections are welcome) is that the text pane does some
calculations with the width of the characters within it, and using
those calculations it decides where the cursor goes; but the text pane
isn't smart enough to know about the width of my text fields, which
mess up the calculations.
I would have hoped that JTextPane would be smart enough to use the
width of contained components, but it doesn't seem to be. Or, perhaps,
my implementation does not work the way JTextPane is expecting.
Sadly, even though I have this guess of what the problem is, I don't
know where I would go in the code to fix it. I hope that one of you
will have a suggestion -- my boss isn't very happy with this crazy text
editor panel I've coded up (and neither am I).
peace; and thank you in advance,
Nicholas
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Java-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/java-dev/email@hidden