JDK-6532736 : A blocked Window appears above a modal dialog
  • Type: Bug
  • Component: client-libs
  • Sub-Component: java.awt
  • Affected Version: 1.4.2,7
  • Priority: P4
  • Status: Closed
  • Resolution: Fixed
  • OS: generic
  • CPU: generic
  • Submitted: 2007-03-09
  • Updated: 2011-03-07
  • Resolved: 2011-03-07
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
JDK 7
7 b14Fixed
Related Reports
Relates :  
Description
This is reproducable from 1.4.2 onwards on all platforms.

A blocked Window does not go behind a modal dialog when the Window comes up. When clicked anywhere on the Window, the window goes below the Dialog

To reproduce:
1. Run the below test. It shows a Dialog with a button in it
2. Click the button - It'll show a Window.

If the Window appears above the Dialog, the bug is reproduced. Click anywhere on the Window. It could be seen that the Window goes behind the Dialog

import java.awt.*;
import java.awt.event.*;

public class Test { 
    public static void main(String[] args) {
        Dialog d = new Dialog(new Frame());
        d.setModal(true);
        d.setLayout(new FlowLayout());
        final Window w = new Window(new Frame());
        w.setSize(200, 200);
        w.setLocation(100, 100);
        Button b = new Button("Click me");
        b.addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent event) {
                w.setVisible(true);
            }
        });
        d.add(b);
        d.setSize(200, 200);
        d.setVisible(true);
    }
}
There is another problem, specific only to solaris/linux. When the window is shown, it is located above the modal dialog. When I click on the dialog, it comes to front, but subsequent click on the window brings it above the dialog again. On Windows, this doesn't happen: once the dialog is clicked, the window never comes to front (of course, until the dialog is dismissed).

Comments
SUGGESTED FIX Webrev: http://sa.sfbay.sun.com/projects/awt_data/7/6532736
06-04-2007

EVALUATION Linux/Solaris implementation has another problems than on Windows. Actually, I have found two problems: with Z-order which this bug is initially filed about, and with focus. The latter is: when I have a Frame, a Dialog and a Window (both are child windows of the frame), then the blocked window can receive focus, which is incorrect. The first problem (Z-order) seems to be caused by the fact that any XWindowPeer (a peer for Window, not Frame or Dialog) is never reparented: isReparented() always returns false. This leads to the window is never added to the transient_for chain and can be raised above the blocking dialog. The second problem (with focus) can also be understood easily. For any decorated windows (Frame or Dialog) we set WM_TAKE_FOCUS atom and window manager sends us the corresponding messages. In WM_TAKE_FOCUS handler we check if the window is blocked by some modal dialog and request focus for this dialog instead of original window. However, for non-decorated windows (Window) this is not implemented: we don't get WM_TAKE_FOCUS and don't activate the blocking dialog.
19-03-2007

EVALUATION On Windows platform: when a window is shown, we check if it should be blocked by some (already shown) modal dialog. It is performed at the method Window.show() (in JDK 6 and 7). However, at the time of check, the window's peer is created but not visible yet, so ::BringWindowToTop() call for dialog does nothing. We should bring it to top only after a blocked window is shown. I suspect something similiar happens on Linux/Solaris platform.
09-03-2007