JTextComponent highlight and text selection

Hello,

I'm working with subclass of TextPane which use a subclass of DefaultStyledDocument. I had to write my own text selection highlight because a Paragraph element contains many level of other elements and I had to prevent that a user selects an highlight just a part of theses elements : only a entire element must be selected and highlight .

I overwrite the JTextComponent select(...) method, but it doesn't work.

Could you help me ?

[466 byte] By [ScientificWarea] at [2007-11-26 18:52:41]
# 1

Hi ScientificWare !

Use the select method in JTextComponent if you know the start offset and the end offset in your document. For example, if you want to add a select all item in a menu the action will be select(doc.getStartOffset, doc.getEndOffset).

For you problem have a look in the BasicTextUI.BasicCaret class.

...

ScientificWarea at 2007-7-9 6:26:44 > top of Java-index,Desktop,Core GUI APIs...
# 2
I think you had to subclass the DefaultCaret class and overwrite moveDot method.Have a look to the moveCaret(MouseEvent e) method too.
ScientificWarea at 2007-7-9 6:26:44 > top of Java-index,Desktop,Core GUI APIs...
# 3
Multipersonality Disorder reported!!!
Rodney_McKaya at 2007-7-9 6:26:44 > top of Java-index,Desktop,Core GUI APIs...
# 4
No problem ! But when you ask for help and you find the solution, I think you had to give this solution. If you've got a best way to answer, say it !
ScientificWarea at 2007-7-9 6:26:44 > top of Java-index,Desktop,Core GUI APIs...
# 5
That's fine, but I don't see how this is related to saying hi to yourself...
Rodney_McKaya at 2007-7-9 6:26:44 > top of Java-index,Desktop,Core GUI APIs...
# 6
> That's fine, but I don't see how this is related to> saying hi to yourself...I agree, this is one of the most disturbing posts I have seen on this forum.
zadoka at 2007-7-9 6:26:44 > top of Java-index,Desktop,Core GUI APIs...