Maintain Selection in a JTextPane

J

Jason Cavett

I have a JTextPane where I want to maintain selection of the text
regardless of any other components I may be clicking or using.
Unfortunately, no matter what I have tried, every time I select
anything else (AKA, the JTextPane loses focus), the selection also
disappears.

Is there some (relatively easy) way to fix this that I'm not seeing,
or is this something that is going to require me to overwrite a bunch
of methods in JTextPane? (Basically, I want to make sure I'm not
overlooking something obvious when trying to solve this problem.)


Thanks
 
J

Jason Cavett

I have a JTextPane where I want to maintain selection of the text
regardless of any other components I may be clicking or using.
Unfortunately, no matter what I have tried, every time I select
anything else (AKA, the JTextPane loses focus), the selection also
disappears.

Is there some (relatively easy) way to fix this that I'm not seeing,
or is this something that is going to require me to overwrite a bunch
of methods in JTextPane?  (Basically, I want to make sure I'm not
overlooking something obvious when trying to solve this problem.)

Thanks

Cardboard Programmer.

I figured it out. In case anybody else is curious, you need to
overwrite the caret of the text field so that it does not
automatically disappear on focus lost. It's actually pretty simple to
do.

Thanks.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,997
Messages
2,570,239
Members
46,827
Latest member
DMUK_Beginner

Latest Threads

Top