> Brandon McCombs napisal(a):
> >
[quoted text clipped - 5 lines]
> Sorry. I forget say I don't want to prevent component from puting text
> in it but only whilst selecting text in it. Is it imposible?
Try subclassing JTextField. When the mouseDrag event fires inside the
JTextField do something like return immediately or set the focus on the
parent JComponent. You will want to catch keyboard input also. (Block
things like ctrl+A, ctrl+C, shift+end and shift+home)
I think it can be done but it will require some hacking and time. There
may be a better way but this is what I can figure.
Good luck,
Mearvk
Andrew Thompson - 29 Dec 2006 13:34 GMT
...
> > ...I forget say I don't want to prevent component from puting text
> > in it but only whilst selecting text in it. Is it imposible?
....
> I think it can be done but it will require some hacking and time. There
> may be a better way ...
How about - an entirely different /strategy/ in
following 'the path of least surprise' in the use
of GUI components?
It is nonsensical to allow editing of a text field, but
disallow selecting the text (I would normally select
the text simply to delete the content, but if this
scheme were implemented - i'd need to hit 'del, del,
del, del, ..oh heck I'll just use the software of their
direct competitor, instead..').
Andrew T.
dako - 04 Jan 2007 10:04 GMT
Andrew Thompson napisal(a):
> It is nonsensical to allow editing of a text field, but
> disallow selecting the text....
Sorry, but I don't agree with you. It is't nonsensical. You should
remember that necessity is the mother of invention. Apparently somebody
needed the solution as well, because exist special method:
jTextField_userStreet.setHighlighter(null);
Regards, dako.
dako - 04 Jan 2007 09:36 GMT
mearvk napisal(a):
> Try subclassing JTextField. When the mouseDrag event fires inside the
> JTextField do something like return immediately or set the focus on the
[quoted text clipped - 3 lines]
> I think it can be done but it will require some hacking and time. There
> may be a better way but this is what I can figure.
The solution is easier than you think ;) Look at John's post.
Regards, dako.
> Sorry. I forget say I don't want to prevent component from puting text
> in it but only whilst selecting text in it. Is it imposible?
Try to use a JLabel instead.
Bye.

Signature
Real Gagnon from Quebec, Canada
* Looking for Java or PB code examples ? Visit Real's How-to
* http://www.rgagnon.com/howto.html
dako - 04 Jan 2007 09:15 GMT
Real Gagnon napisal(a):
> Try to use a JLabel instead.
I've already known the solution thanks to John. I might try
JTextField.setHighlighter(null) so the idea is redundant.
Regards, dako