Efficient way to capture all keyboard input

T

Timasmith

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
 
F

Fred Kleinschmidt

Timasmith said:
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.
 
T

Timasmith

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.
 
L

Larry Barowski

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?
 
L

liang.spark

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.
 
T

Timasmith

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.
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,995
Messages
2,570,231
Members
46,820
Latest member
GilbertoA5

Latest Threads

Top