Efficient way to capture all keyboard input

Discussion in 'Java' started by Timasmith, Feb 12, 2007.

  1. Timasmith

    Timasmith Guest

    Hi,

    I have a frame with several splitpanes or panels. In general those
    are navigation orientated - tab, arrow up, arrow down, click etc.

    Whenever a user starts typing letters I want to place focus into a
    particular (default) field. Of course if you are already in a text
    field I would ignore it.

    What is the most efficient way to do this without bogging down every
    keystroke with overhead?

    thanks

    Tim
    Timasmith, Feb 12, 2007
    #1
    1. Advertising

  2. "Timasmith" <> wrote in message
    news:...
    > Hi,
    >
    > I have a frame with several splitpanes or panels. In general those
    > are navigation orientated - tab, arrow up, arrow down, click etc.
    >
    > Whenever a user starts typing letters I want to place focus into a
    > particular (default) field. Of course if you are already in a text
    > field I would ignore it.
    >
    > What is the most efficient way to do this without bogging down every
    > keystroke with overhead?
    >
    > thanks
    >
    > Tim
    >

    I think you need to clarify (to yourself and to us) what you
    really mean to accomplish. The user is navigating around for
    a purpose - usually to get the focus to a particular field.

    You are going to cause the user a lot of grief if she then starts typing,
    only to have the text go into a different field than she has
    just navigated to. So she clicks in the desired field and then
    starts typing. But no! you said that when she starts typing letters,
    the input goes to the default field, not the one she is trying
    to type into! She tries again, and again to no avail. Now she is
    really angry, and finally just discards the entire app and goes to
    a different vendor.
    --
    Fred L. Kleinschmidt
    Boeing Associate Technical Fellow
    Technical Architect, Software Reuse Project
    Fred Kleinschmidt, Feb 12, 2007
    #2
    1. Advertising

  3. Timasmith

    Timasmith Guest

    On Feb 12, 6:14 pm, "Fred Kleinschmidt"
    <> wrote:
    > "Timasmith" <> wrote in message
    >
    > news:...
    >
    >
    >
    > > Hi,

    >
    > > I have a frame with several splitpanes or panels. In general those
    > > are navigation orientated - tab, arrow up, arrow down, click etc.

    >
    > > Whenever a user starts typing letters I want to place focus into a
    > > particular (default) field. Of course if you are already in a text
    > > field I would ignore it.

    >
    > > What is the most efficient way to do this without bogging down every
    > > keystroke with overhead?

    >
    > > thanks

    >
    > > Tim

    >
    > I think you need to clarify (to yourself and to us) what you
    > really mean to accomplish. The user is navigating around for
    > a purpose - usually to get the focus to a particular field.
    >
    > You are going to cause the user a lot of grief if she then starts typing,
    > only to have the text go into a different field than she has
    > just navigated to. So she clicks in the desired field and then
    > starts typing. But no! you said that when she starts typing letters,
    > the input goes to the default field, not the one she is trying
    > to type into! She tries again, and again to no avail. Now she is
    > really angry, and finally just discards the entire app and goes to
    > a different vendor.
    > --
    > Fred L. Kleinschmidt
    > Boeing Associate Technical Fellow
    > Technical Architect, Software Reuse Project- Hide quoted text -
    >
    > - Show quoted text -


    If you anywhere on the (tab/frame) which is not a text field then
    pressing a letter would take you do the default text field.

    Most commonly in this application you would be in a table or a list,
    when you start to type it takes you to the default text field.
    Timasmith, Feb 13, 2007
    #3

  4. > If you anywhere on the (tab/frame) which is not a text field then
    > pressing a letter would take you do the default text field.
    >
    > Most commonly in this application you would be in a table or a list,
    > when you start to type it takes you to the default text field.


    You are aware that JList has keyboard navigation using
    "letter" keys, right?
    Larry Barowski, Feb 13, 2007
    #4
  5. Timasmith

    Guest

    On 2ÔÂ12ÈÕ, ÉÏÎç11ʱ01·Ö, "Timasmith" <> wrote:
    > Hi,
    >
    > I have a frame with several splitpanes or panels. In general those
    > are navigation orientated - tab, arrow up, arrow down, click etc.
    >
    > Whenever a user starts typing letters I want to place focus into a
    > particular (default) field. Of course if you are already in a text
    > field I would ignore it.
    >
    > What is the most efficient way to do this without bogging down every
    > keystroke with overhead?
    >
    > thanks
    >
    > Tim


    try this:

    KeyStroke enter= KeyStroke.getKeyStroke(KeyEvent.VK_ENTER,0,false); //
    define a key stroke for "enter"
    Action keyAction = new AbstractAction() {
    public void actionPerformed(Event e){
    System.out.println("Enter is pressed!");
    }
    };
    JPanel c=(JPanel) getContentPane(); // c is the top JComponent on your
    main frame.
    c.getInputMap(JComponent.WHEN_FOCUSED_WINDOW).put(enter,"enter");
    c.getActionMap().put("enter",keyAction);

    put above code into your Frame initialized mothed.
    , Feb 14, 2007
    #5
  6. Timasmith

    Timasmith Guest

    On Feb 13, 12:47 pm, "Larry Barowski" <MElarrybar-AT-
    eng_DOT_auburnANOTHERDOTeduEND> wrote:
    > > If you anywhere on the (tab/frame) which is not a text field then
    > > pressing a letter would take you do the default text field.

    >
    > > Most commonly in this application you would be in a table or a list,
    > > when you start to type it takes you to the default text field.

    >
    > You are aware that JList has keyboard navigation using
    > "letter" keys, right?


    Yes, but I never use a JList - I only ever use JTable as I always end
    up adding columns to a list.

    Keyboard navigation by letter is not useful if your list items, a
    subset of the results, primarily all begin with the same letter.
    Timasmith, Feb 15, 2007
    #6
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Replies:
    4
    Views:
    667
    Walter Roberson
    Sep 9, 2005
  2. Support Desk
    Replies:
    0
    Views:
    362
    Support Desk
    Feb 27, 2009
  3. Shane Geiger
    Replies:
    0
    Views:
    478
    Shane Geiger
    Feb 27, 2009
  4. Support Desk
    Replies:
    0
    Views:
    641
    Support Desk
    Feb 27, 2009
  5. Mark
    Replies:
    10
    Views:
    234
Loading...

Share This Page