I am creating a text editor using JTextPane that allows the user to bold, color and align the text by highlighting the text then selecting the option to either bold, color or align. After the adjustment is made, the selection goes away, but I want it to stay. Is there a way to get it to stay, or should I manually reselect the text? If so, how can I do that?
Asked
Active
Viewed 1,630 times
-1
-
`After the adjustment is made, the selection goes away` - Assuming you are using the suggestion from your last question on this topic, the selection does not go away. If you ignored the suggestion and wrote your own code then we can't help because you didn't post a `SSCCE`. Also, you haven't accepted any answers yet. – camickr Sep 25 '13 at 20:59
-
Yes, I did try the suggestion from my last post- should have posted an update. A combination of the provided examples with suggestions found elsewhere ended up working for me. But the text selection still went away after an change to the test style was made. But I was able to fix this by setting focusable on the buttons to be false and some other minor tweaks. Thank you for your help and I apologize for my insufficient response to suggestions and lack of source code. – smith8ar Sep 30 '13 at 15:53
1 Answers
2
The example in Oracle's Java Tutorials does what you need and provides the source code.

Igor Rodriguez
- 1,196
- 11
- 16
-
-
1You've already been give a link to the example in your previous question on this topic: http://stackoverflow.com/q/18877688/131872. – camickr Sep 25 '13 at 20:51