如果用户单击 IE 窗格,则 IE 中的模态对话框会隐藏在 IE 后面 [英] Modal dialogs in IE gets hidden behind IE if user clicks on IE pane

查看:27
本文介绍了如果用户单击 IE 窗格,则 IE 中的模态对话框会隐藏在 IE 后面的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我必须编写一个显示密码对话框的小程序.问题是对话框设置为始终在顶部,但是当用户单击 IE 窗口时,对话框仍然隐藏在 IE 窗口后面.并且由于对话框是模态的并且包含所有 IE 线程,因此 IE 窗格不会刷新并且对话框窗口仍然绘制在 IE 之上(但不会刷新).这种行为使用户感到困惑(他们看到 IE 顶部的对话框,但由于未刷新,该对话框看起来已挂起).

I have to write an applet that brings up a password dialog. The problem is that dialog is set to be always on top but when user clicks on IE window dialog gets hidden behind IE window nevertheless. And since dialog is modal and holds all IE threads IE pane does not refresh and dialog window is still painted on top of IE (but not refreshed). This behaviour confuses users (they see dialog on top of IE but it looks like it has hanged since it is not refreshe).

所以我需要一种方法来使该对话框始终处于最重要的位置.但是这个问题的任何其他解决方案都会很好.

So I need a way to keep that dialog on top of everything. But any other solution to this problem would be nice.

代码如下:

        PassDialog dialog = new PassDialog(parent);
        /* do some non gui related initialization */
        dialog.pack();
        dialog.setLocationRelativeTo(null);
        dialog.setAlwaysOnTop(true);
        dialog.setVisible(true);

解决方案:正如@shemnon 指出的那样,我应该创建一个窗口而不是模态对话框的 (null, Frame, Applet) 父级.初始化父级的好方法是:

Resolution: As @shemnon noted I should make a window instead of (null, Frame, Applet) parent of modal dialog. So good way to initlialize parent was:

parent = javax.swing.SwingUtilities.getWindowAncestor(theApplet);

推荐答案

你对父级使用什么参数?

What argument are you using for the parent?

如果您使用 Applet 的父级,您的运气可能会更好.

You may have better luck if you use the parent of the Applet.

javax.swing.SwingUtilities.getWindowAncestor(theApplet)

使用 getWindowAncestor 将跳过小程序的父级(getRoot(component) 将返回小程序).至少在某些 Java 版本中,有一个相当于 IE 窗口的框架.天啊.

Using the getWindowAncestor will skip the applet parents (getRoot(component) will return applets). In at least some versions of Java there was a Frame that was equivalent to the IE window. YMMV.

这篇关于如果用户单击 IE 窗格,则 IE 中的模态对话框会隐藏在 IE 后面的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆