Results 1 to 5 of 5
  1. #1
    gary is offline Member
    Join Date
    Jun 2007
    Posts
    8
    Rep Power
    0

    Default help with JTextfield

    Can anyone help

    I have a group of JTextFields and when the user inputs a certain number of characters I would like to program to focus on the next field.

  2. #2
    JavaBean's Avatar
    JavaBean is offline Moderator
    Join Date
    May 2007
    Posts
    1,270
    Rep Power
    10

    Default

    Hmm, in the way you want it to be implemented, this is a little bit complex problem. Because you can't know when the user finished his job with a textfied!! You can just guess it!

    How you can guess it? You can listen textfield for a specified time period which is acceptable by your users. For example once user starts typing, you can count number of milliseconds passed from the last character entered! When this passes a certain threshold, you can decide that the user finished his job with that textfield and transfer the focus to the other one. And you will need to implement this in a separate thread!

    In my opinion, if your application is not targeting to a very specific data entry job, this is not the correct way to implement entering data. Because today or tomorrow, your users will not be satisfied with the threshold selected above. You can control focus with tab key (focus transferred when user press tab key) or you can think about a more innovative way of getting the data (e.g. via an input file).

  3. #3
    gary is offline Member
    Join Date
    Jun 2007
    Posts
    8
    Rep Power
    0

    Default

    my application is targeted to a specif type of data entry and each textfield will always have the same ammount of characters inputed.

  4. #4
    JavaBean's Avatar
    JavaBean is offline Moderator
    Join Date
    May 2007
    Posts
    1,270
    Rep Power
    10

    Default

    my application is targeted to a specif type of data entry and each textfield will always have the same ammount of characters inputed.
    Then it is easier. Check the number of characters and activity of textfields with a thread and change focus when user enters required number of characters.

  5. #5
    gary is offline Member
    Join Date
    Jun 2007
    Posts
    8
    Rep Power
    0

    Default

    thanks but im a little slow when it comes to java, do you have a good example or link I could look at. ta.

Similar Threads

  1. how to focus to another JTextfield?
    By birdofprey in forum AWT / Swing
    Replies: 2
    Last Post: 04-09-2008, 01:08 PM
  2. Using Columns With JTextField
    By The Evil Genius in forum AWT / Swing
    Replies: 1
    Last Post: 03-17-2008, 01:01 AM
  3. Can't edit JTextField after modal dialog
    By JavaNerd in forum Java Applets
    Replies: 0
    Last Post: 02-07-2008, 09:11 PM
  4. Clean the content of the JTextField
    By elizabeth in forum AWT / Swing
    Replies: 1
    Last Post: 07-26-2007, 08:38 PM
  5. Replies: 1
    Last Post: 05-20-2007, 11:19 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •