恢复焦点Java小程序时,浏览器/标签获得焦点 [英] Restore focus to Java Applet when Browser/Tab gains focus
问题描述
我有一个小应用程序在浏览器中运行的标签。当我切换到在同一浏览器不同的选项卡,或ALT-TAB到另一个应用程序完全,小应用程序失去焦点。当我返回到浏览器选项卡中,小程序不会获得重新对焦。有没有一个好的方法来实现这一目标?
I have an applet running in a browser tab. When I switch to a different tab in the same browser, or ALT-TAB to another application entirely, the applet loses focus. When I return to the browser tab, the applet doesn't gain focus again. Is there a nice way to make this happen?
我想这是一个的需要,而不是在小程序本身一个JavaScript的改变?一些的onfocus处理程序吧?如果是相关的,是使用HTML创建了自己的小程序<小程序方式>
标签
I assume it's a JavaScript change that's needed, not in the applet itself? Some onFocus handler perhaps? If it's relevant, our applet is created using an HTML <applet>
tag.
推荐答案
我相信Java有 requestFocus()方法
方法。这是在组件类,所以您的JPanel或任何你正在使用可能能够使用它。
I believe java has the requestFocus()
method. It's in the Component class, so your JPanel or whatever you are using may be able to use this.
有关的JavaScript的一部分,这是一个快速谷歌搜索揭示了什么: HTTP://www.raditha .COM / JAVA / javascript.php 。我希望它可以帮助你!
For the javascript part, this is what a quick googling reveals: http://www.raditha.com/java/javascript.php. I hope it helps you!
这篇关于恢复焦点Java小程序时,浏览器/标签获得焦点的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!