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 2 of 2

Thread: Using Keyevent

  1. #1
    Junior Member
    Join Date
    Apr 2012
    Posts
    18
    Thanks
    2
    Thanked 0 Times in 0 Posts

    Default Using Keyevent

    String mess = "Hello".
    I want to use JOptionPane.ShowInputDialog and if the user presses backspace, the code is supposed to remove the last letter of 'mess'.
    But I have NO IDEA how to use KeyListener or Keyevent. So could anyone show me a simple code to show me how to use those methods?
    I looked at many other sources, but the codes are only fragments and i am too much of a noob to figure out the rest.


  2. #2
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    22,346
    Thanks
    56
    Thanked 2,376 Times in 2,346 Posts

    Default Re: Using Keyevent

    There are some examples here:
    How to Write a Key Listener (The Java™ Tutorials > Creating a GUI With JFC/Swing > Writing Event Listeners)
    Start with a simple program that catches key events and work with it to see how it key events work.
    If you don't understand my answer, don't ignore it, ask a question.

Similar Threads

  1. KeyEvent Running Twice?
    By JuLiAnc in forum What's Wrong With My Code?
    Replies: 2
    Last Post: January 10th, 2012, 04:43 PM