Results 1 to 6 of 6
  1. #1
    akshaydusane is offline Member
    Join Date
    May 2012
    Posts
    22
    Rep Power
    0

    Default Want to work with keypress method

    Hello guys
    I want to use keypress method in my project
    Suppose there is a button I want to activate this button function by pressing enter key or any particular key
    How to do this ??
    please help...

  2. #2
    doWhile is offline Moderator
    Join Date
    Jul 2010
    Location
    California
    Posts
    1,641
    Rep Power
    7

    Default Re: Want to work with keypress method

    I'd recommend providing more context to your question: the amount of information provided leads to people guessing...I can guess you are referring to Swing, and can guess that you might want to look at using KeyBindings (keep in mind this is a guess which, if doesn't help please provide more information):
    How to Use Key Bindings (The Java™ Tutorials > Creating a GUI With JFC/Swing > Using Other Swing Features)

  3. #3
    akshaydusane is offline Member
    Join Date
    May 2012
    Posts
    22
    Rep Power
    0

    Default Re: Want to work with keypress method

    I am working in netbeans...
    I have created one form . In that form I have took a button and a textfield..
    I want to write something in textfield

    private void jButton1ActionPerformed(java.awt.event.ActionEvent evt)
    {
    jTextField1.setText("ABC");
    }

    I want to invoke this method by pressing enter key or any particular key..
    how to do this??

  4. #4
    doWhile is offline Moderator
    Join Date
    Jul 2010
    Location
    California
    Posts
    1,641
    Rep Power
    7

    Default Re: Want to work with keypress method

    Did you read the tutorial above? It clearly demonstrates how to use key bindings to accomplish your requirement.

  5. #5
    akshaydusane is offline Member
    Join Date
    May 2012
    Posts
    22
    Rep Power
    0

    Default Re: Want to work with keypress method

    Sorry sir I am not understanding...

    can you explain me in simple words ?

  6. #6
    doWhile is offline Moderator
    Join Date
    Jul 2010
    Location
    California
    Posts
    1,641
    Rep Power
    7

Similar Threads

  1. How does the clone() method work?
    By EscSequenceAlpha in forum New To Java
    Replies: 7
    Last Post: 05-25-2012, 08:05 PM
  2. How does System.out.println() method work?
    By fatabass in forum New To Java
    Replies: 4
    Last Post: 01-17-2012, 12:04 PM
  3. Method won't work even though program compiles
    By NixasMuraki in forum New To Java
    Replies: 10
    Last Post: 02-14-2011, 10:39 PM
  4. help~ delete method cant work
    By reeveliew in forum New To Java
    Replies: 4
    Last Post: 05-07-2010, 03:24 AM
  5. KeyPress for my Button
    By bigj in forum New To Java
    Replies: 3
    Last Post: 01-26-2010, 05:27 PM

Posting Permissions

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