oracle - Applet Java 7 update 21: Cannot set AWTKeyListener on default Toolkit -


in self-signed applet (that may possibly become ca-signed applet in near future) in have complex swing gui, need detect whenever user has shift- or control-key pressed. using in combination component-related mouseevents , mousemotionevents special mouse-event processing @ time. shortly:

when recieve mouse-motion-event on distinct component need detect whether control or shift being held down (pressed). problem is, user press down shift/control before he/she moves mouse component of interest. real "usability" problem!

prior java 7 update 21 able accomplish using jvm-global awtkeylistener added default toolkit. no longer allowed (due security requirements of java 7 update 21 - , in despite of, jnlp-launching applet in distinct , separate jvm, that's talk).

so have:

i have tried register keylistener "main" panel of applet, key-events seem "swallowed" (by whatever component in gui having keyboad focus).

then have tried using key-bindings main-panel (the top-level container), adding bindings "shift", "control" , "escape". binding working "escape", , hits "released" action. "shift" , "control" never hit (notified). using when_in_focused_window input-map of main-panel.

i need detect keyboard events application-wide (and not jvm-wide). how can accomplish that? possible "intercept" keyboard-events @ level in component-hierarchy other means?

i don't mind overriding swing/awt methods in order accomplish - desparete find solution.

i appreciate suggestions, otherwise discourage customers updating java 7 upd 21. thanks!

aron

ps: why there no support "application"-global resources in java. goes authenticators, keylisteners, default locale etc..? on jvm-global basis, despite (as applet developers) need @ application level.

you can use methods on event you're passed determine current state of modifier keys. event.iscontroldown(), example, tell if control key still pressed when mouse event in question occurred. likewise, can call event.isshiftdown() shift key.


Comments

Popular posts from this blog

c# - Send Image in Json : 400 Bad request -

javascript - addthis share facebook and google+ url -

ios - Show keyboard with UITextField in the input accessory view -