开发者

Prevent Java Applet from gaining Focus

开发者 https://www.devze.com 2023-01-18 17:48 出处:网络
An applet gains focus when loaded, preventing browser keystrokes from wo开发者_如何转开发rking. You can work around this by adding a parameter to the applet tag:

An applet gains focus when loaded, preventing browser keystrokes from wo开发者_如何转开发rking. You can work around this by adding a parameter to the applet tag:

name="initial_focus" value="false"

So far so good. But when the user clicks on the applet even if the applet does not have any user interface controls, then the problem remains.

I guess another way to phrase the question is: How can I get the applet to forward all keystrokes back to the browser?


You can attach a button click handler to the parts of your application that doesn't have a UI (for example your root pane), and execute a piece of javascript code that will be run by the browser, delegating the focus to some HTML DOM element instead.

0

精彩评论

暂无评论...
验证码 换一张
取 消