Focus on JTextField

Discussion in 'Java' started by kunju, Apr 2, 2006.

  1. kunju

    kunju New Member

    Joined:
    Mar 26, 2006
    Messages:
    9
    Likes Received:
    0
    Trophy Points:
    0
    hello,

    How can I set the cursor at the desired TextField? By defualt it sets in the
    first TextField. I want to set in to the secon TextField?What is the method
    using in Java? like any setFocuse()?

    pls reply..
     
  2. coderzone

    coderzone Super Moderator

    Joined:
    Jul 25, 2004
    Messages:
    736
    Likes Received:
    38
    Trophy Points:
    28
    You need to call requestFocus() on the JTextField.
     
  3. Amit Ray

    Amit Ray New Member

    Joined:
    Jul 12, 2004
    Messages:
    75
    Likes Received:
    4
    Trophy Points:
    0
    Occupation:
    Software Developer
    Home Page:
    http://www.go4expert.com
    Please look at requestFocus and requestFocusInWindow methods of the JComponent from the Java API docs : Focus Request Methods .

    It is generally advised to use the later and avoid the requestFocus method whenever possible.

    Amit Ray.
     
  4. coderzone

    coderzone Super Moderator

    Joined:
    Jul 25, 2004
    Messages:
    736
    Likes Received:
    38
    Trophy Points:
    28

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice