Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 4 of 4

Thread: Problem with KeyListener

  1. #1
    Junior Member r12ki's Avatar
    Join Date
    May 2009
    Posts
    8
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default Problem with KeyListener

    Hello there...

    I need your help more. Now I have problem with JButton. I want the button listen for ENTER key. Logically, when I press ENTER key, it'll execute submit command. Can you help me solve this...

    Thanx for all attentions...


  2. #2
    Senile Half-Wit Freaky Chris's Avatar
    Join Date
    Mar 2009
    Posts
    834
    My Mood
    Cynical
    Thanks
    7
    Thanked 105 Times in 90 Posts

    Default Re: Problem with KeyListener

    will focus be on the JButton? or will it b on a text box control? Because lets say for instance its a login screen then you want to listen to the Enter command on the password textarea to save people tabbing to the button, although you would want to listen for enter on the button also.

    Maybe this will be a clue, http://www.javaprogrammingforums.com...ava-swing.html

    Chris

  3. The Following User Says Thank You to Freaky Chris For This Useful Post:

    r12ki (July 31st, 2009)

  4. #3
    Junior Member r12ki's Avatar
    Join Date
    May 2009
    Posts
    8
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default Re: Problem with KeyListener

    I mean on JButton only

  5. #4
    Junior Member
    Join Date
    Oct 2009
    Posts
    7
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: Problem with KeyListener

    Try this, r12ki:

    this.getRootPane().setDefaultButton(btnOK);

    Cheers,

    Sean C.
    PekinSOFT Systems

Tags for this Thread