Results 1 to 5 of 5

Thread: How to use Key Bindings in Java?

  1. #1
    Join Date
    Aug 2006
    Posts
    253

    How to use Key Bindings in Java?

    Hi friends,
    I am new for the Java. I have done some basic things in the Core Java. Before that I have completed with C++ programming language. Now I want to do the key binding in my application which I am finding very difficult to do. So expecting some help from you guys. Please tell me how to use Key Bindings in Java.?? Hope that someone would help me quickly.!!

  2. #2
    Join Date
    Nov 2008
    Posts
    996

    Re: How to use Key Bindings in Java?

    The JComponent class supports key bindings as a way of responding to individual keys typed by a user. All Swing components use Key Bindings. The following are some examples of when key bindings can be used :
    • When you want to override the behavior of an existing key binding.
    • When you're creating a custom component and want to support keyboard access to it.
    • When you want to provide a new key binding for an existing action.

  3. #3
    Join Date
    Nov 2008
    Posts
    1,192

    Re: How to use Key Bindings in Java?

    An alternative to key bindings is using key listeners. Key listeners are also difficult if the key binding is to be active when the component doesn't have focus. Swing uses an InputMap, to contain the KeyStrokes and an ActionMap to contain the Actions. The JComponent class supports key bindings as a way of responding to individual keys typed by a user. You often don't need to use key bindings directly. They're used behind the scenes by mnemonics.

  4. #4
    Join Date
    Mar 2008
    Posts
    672

    Re: How to use Key Bindings in Java?

    Each JComponent has one action map and three input maps. You can check the following :
    Code:
    JComponent.WHEN_FOCUSED
    The component has the keyboard focus. The WHEN_FOCUSED input map is typically used when the component has no children.

  5. #5
    Join Date
    Feb 2008
    Posts
    1,852

    Re: How to use Key Bindings in Java?

    The input maps correspond to the following focus :
    Code:
     JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT
    The component contains (or is) the component that has the focus. This input map is commonly used for a composite component — a component whose implementation depends on child components.

Similar Threads

  1. Replies: 4
    Last Post: 21-04-2012, 05:39 PM
  2. Key bindings broken in Battlefield 3
    By Amul in forum Video Games
    Replies: 9
    Last Post: 31-10-2011, 11:32 AM
  3. Replies: 5
    Last Post: 03-09-2011, 10:58 PM
  4. What are the Key Bindings in Achron game?
    By Chrirag 1 in forum Video Games
    Replies: 6
    Last Post: 30-08-2011, 07:18 PM
  5. How to do key bindings on Gnome 3?
    By MEDINI in forum Windows Software
    Replies: 5
    Last Post: 24-06-2011, 10:23 AM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Page generated in 1,713,508,536.84459 seconds with 17 queries