Customising Swing JTextField

D

David

Hi,

Im trying to create a custom text box. What I have done is inherited
from the JTextField class, and attached key listeners. However,
obviously swing is calling my listeners then processing the JTextFields
ones. Without using the formatter etc... I want to block key events
from being processed by JTextField. Any ideas how I can achieve this?
Ive tried looking at the source, but just cant seem to find any way to
do this apart from Key-Binding every key on the keyboard, which seems
insane. Im sure theres something easy im missing.

Thanks for the help

David
 
H

hiwa

David said:
Hi,

Im trying to create a custom text box. What I have done is inherited
from the JTextField class, and attached key listeners. However,
obviously swing is calling my listeners then processing the JTextFields
ones. Without using the formatter etc... I want to block key events
from being processed by JTextField. Any ideas how I can achieve this?
Ive tried looking at the source, but just cant seem to find any way to
do this apart from Key-Binding every key on the keyboard, which seems
insane. Im sure theres something easy im missing.

Thanks for the help

David
Yours may be DocumentFilter's job.
 
K

Kenneth P. Turvey

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Hi,

Im trying to create a custom text box. What I have done is inherited from
the JTextField class, and attached key listeners. However, obviously swing
is calling my listeners then processing the JTextFields ones. Without
using the formatter etc... I want to block key events from being processed
by JTextField. Any ideas how I can achieve this? Ive tried looking at the
source, but just cant seem to find any way to do this apart from
Key-Binding every key on the keyboard, which seems insane. Im sure theres
something easy im missing.

On a related topic, I would like to move some spell checking code from a
class I have now into a SpellCheckedTextArea, so some pointers on how best
to subclass a TextArea would also be helpful. Pointers to good references
would work as well.

Thanks.

- --
Kenneth P. Turvey <[email protected]>
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.2.2 (GNU/Linux)

iD8DBQFFVpmai2ZgbrTULjoRAr21AJkBOC6TmDEnTSf+G5Rf+kK4rlbAqACfR/AH
6VfvZWZeFoADuCMVVvJvluE=
=pEx/
-----END PGP SIGNATURE-----
 

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

No members online now.

Forum statistics

Threads
473,781
Messages
2,569,615
Members
45,301
Latest member
BuyPureganics

Latest Threads

Top