Results 1 to 3 of 3
Like Tree1Likes
  • 1 Post By yemista

Thread: registering KeyEvents on a JComponent

  1. #1
    yemista is offline Member
    Join Date
    Oct 2011
    Posts
    41
    Rep Power
    0

    Default registering KeyEvents on a JComponent

    How do I add a key listener to a JComponent? The documentation seems to indicate that KeyListeners can only be on certain kinds of components like JTextArea and the like, bu tIm trying to implement a drawing program and would like ctrl+z functionality, and I need the component all the drawing is happening on to register key events.

  2. #2
    yemista is offline Member
    Join Date
    Oct 2011
    Posts
    41
    Rep Power
    0

    Default Re: registering KeyEvents on a JComponent

    never mind, i did more research and apparently the way to go is an input map? is this correct?
    DarrylBurke likes this.

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

    Default Re: registering KeyEvents on a JComponent

    Quote Originally Posted by yemista View Post
    never mind, i did more research and apparently the way to go is an input map? is this correct?
    The following gives a pretty clear demo for how to do this: How to Use Key Bindings (The Java™ Tutorials > Creating a GUI With JFC/Swing > Using Other Swing Features)

Similar Threads

  1. Key press not registering as ENTER
    By trader5050 in forum New To Java
    Replies: 2
    Last Post: 07-15-2011, 10:43 PM
  2. Command not registering.
    By Kuetsum in forum New To Java
    Replies: 3
    Last Post: 01-18-2011, 08:19 AM
  3. Replies: 2
    Last Post: 10-01-2010, 08:18 PM
  4. Multiple email greetings on registering.
    By MadJack in forum Suggestions & Feedback
    Replies: 0
    Last Post: 09-27-2010, 12:05 AM
  5. Registering problem
    By trini32 in forum New To Java
    Replies: 1
    Last Post: 06-25-2009, 05:35 AM

Posting Permissions

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