1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

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:
    734
    Likes Received:
    37
    Trophy Points:
    0
    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:
    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:
    734
    Likes Received:
    37
    Trophy Points:
    0

Share This Page