Customising Swing JTextField

Discussion in 'Java' started by David, Nov 11, 2006.

  1. David

    David Guest

    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
    David, Nov 11, 2006
    #1
    1. Advertising

  2. David wrote:
    > Im trying to create a custom text box. Without using the formatter etc...


    Why? What's wrong with JFormattedTextField?

    Richard
    Richard Wheeldon, Nov 11, 2006
    #2
    1. Advertising

  3. David

    hiwa Guest

    David wrote:
    > 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.
    hiwa, Nov 12, 2006
    #3
  4. -----BEGIN PGP SIGNED MESSAGE-----
    Hash: SHA1

    On Sat, 11 Nov 2006 11:33:48 -0800, David wrote:

    > 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 <>
    -----BEGIN PGP SIGNATURE-----
    Version: GnuPG v1.4.2.2 (GNU/Linux)

    iD8DBQFFVpmai2ZgbrTULjoRAr21AJkBOC6TmDEnTSf+G5Rf+kK4rlbAqACfR/AH
    6VfvZWZeFoADuCMVVvJvluE=
    =pEx/
    -----END PGP SIGNATURE-----
    Kenneth P. Turvey, Nov 12, 2006
    #4
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. wh1974
    Replies:
    0
    Views:
    2,428
    wh1974
    Jan 12, 2005
  2. Prashanth Ravi
    Replies:
    2
    Views:
    521
    Andrew Thompson
    Oct 7, 2004
  3. Prashanth Ravi
    Replies:
    1
    Views:
    414
    Andrew Thompson
    Oct 7, 2004
  4. brf
    Replies:
    2
    Views:
    865
    Knute Johnson
    Dec 4, 2006
  5. albert kao
    Replies:
    15
    Views:
    1,976
    John B. Matthews
    Mar 12, 2011
Loading...

Share This Page