Key event and focus handling



I'm trying to develop a component (based on a JTabbedPane) where I
manage ALL keyboard events for the component and all components within
it (mostly buttons and labels).

Clicking anywhere in that component (on a tab, or on a button within
the current selected tab) should give the component as a whole focus.
Pressing the Tab key or clicking the mouse outside the component should
move focus off the component and onto other components in my window
(such as text fields), but I don't want Swing or AWT to do any other
focus or key event handling for the main tab pane component.

While the tab pane component as a whole has focus I need ALL key events
to go through a single processKeyEvent method, so I can provide
consistent keyboard shortcuts throughout the component, without having
to worry about subcomponents receiving focus and doing unexpected
processing. In particular, I DON'T want individual buttons to receive
focus and be activated by the space bar, I don't want left and right
arrows to activate other tabs, and so on.

What's the simplest and most robust way to do this? Register a
KeyEventDispatcher? Write my own KeyboardFocusManager? Subclass all the
buttons and other components used in my tab pane, override
processKeyEvent and have them forward the event to a central place?
Register a keyboard action for every possible keystroke? Register an
AWTEventListener? Provide an InputContext?

There are so many possible approaches to this that I can't see the wood
for the trees! (And it doesn't help that Sun completely change the way
key event handling works in every JDK release.)

-Rolf

.



Relevant Pages

  • Re: Unexplained shutdown please help
    ... Open the Control Panel, Regional & Languages options, Languages tab ... is your keyboard and that it is the correct language version. ... Hi Terry - I'm using a dell pc, ...
    (microsoft.public.word.application.errors)
  • Re: Cloud Date Entry
    ... When I was first using windows I wondered why it always wanted a <Tab> ... the typewriter even though it was a multi-line form (she did have to ... I stated that typists use both hands on the keyboard, ... QWERTY or AZERTY used by typists. ...
    (comp.databases.pick)
  • Re: Related to Keypad Driver
    ... GWES sends the keyboard data to the application window that has focus, ... My driver is sending the virtual key from key event to the GWES ...
    (microsoft.public.windowsce.app.development)
  • RE: How to override RichTextBox ProcessCndKey() for text cursor contro
    ... I have tried your code snippet and reproduced out your problem. ... such as TAB, RETURN, ESCAPE, and arrow keys(for keyboard navigation). ... in window procedure of RichEdit control, it will determine if the shift key ...
    (microsoft.public.dotnet.framework.windowsforms.controls)
  • Re: Related to Keypad Driver
    ... different than a regular keyboard. ... Chris Tacke, Embedded MVP ... I am not aware of the mechanism that GWES uses to pass the Virtual Key ... I Have an Event associated with the Key Event. ...
    (microsoft.public.windowsce.app.development)