当用户切换浏览器选项卡时,如何从 JApplet 中隐藏 JDialog?
问题:用户从小程序开始长时间操作;显示带有进度条的 JDialog。用户打开/切换到另一个浏览器选项卡 - JDialog 仍然显示(并且惹恼用户)。
当用户切换到另一个选项卡时,JDialog 应隐藏;当用户切换回来时再次显示。
注意:我看到了类似问题的问题,解决方案是添加 windowActivated/deactivated 侦听器。它对我不起作用,因为窗口中有多个框架,其中一个包含小程序。当用户单击另一个框架时,将引发 windowDeactivate 事件,但用户仍在同一选项卡中。
Problem: user starts long operation from applet; JDialog with progress bar is displayed. User open/switch to another browser tab - JDialog is still displayed (and annoys user).
JDialog should be hidden when user switch to another tab; and displayed again, when user switch back.
Note: I saw question with similar problem, where solution was add windowActivated/deactivated listener. It doesn't work for me, because there are multiple frames in window, and one of them contains applet. When user clicks on another frame, windowDeactivate event is casted, but user still in the same tab.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
尝试将小程序指定为对话框的所有者:
其中“this”是 JApplet。希望这会在每次父母失去焦点时激活/停用对话框。
Try specifying the applet as the owner of the dialog:
where "this" is the JApplet. Hopefully this will activate/deactive the dialog every time the parent loses focus.
解决方案:给所有框架添加监听器
Solution: add listeners to all frames