JDK-6405841 : Showing a new window changes the Z-order for the focused window
  • Type: Bug
  • Component: client-libs
  • Sub-Component: java.awt
  • Affected Version: 6
  • Priority: P2
  • Status: Closed
  • Resolution: Duplicate
  • OS: generic
  • CPU: generic
  • Submitted: 2006-03-29
  • Updated: 2011-01-22
  • Resolved: 2006-04-18
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 6
6Resolved
Related Reports
Duplicate :  
Relates :  
Description
Run the provided test, click the button

Acutal: focused window goes to bottom
Expected: Windows Z-order remains the same

Reproducible on Windows, not reproducible on Solaris

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

public class AwtTest {
    public static void main(String[] args) {
        final Frame frame1 = new Frame("Frame 1");
        frame1.addWindowListener(new WindowAdapter() {
            public void windowClosing(WindowEvent e) {
                System.exit(0);
            }
        });
        Frame frame2 = new Frame("Frame 2");
        final Window w = new Window(frame1);
        w.add(new Button("Window is here"));
        w.pack();
        Button comp = new Button("Click me");
        comp.addActionListener(new ActionListener() {
            public void actionPerformed(ActionEvent e) {
                w.setVisible(false);
                w.setVisible(true);
            }
        });
        frame2.add(comp);
        frame2.pack();
        frame1.setSize(100,100);
        frame1.setVisible(true);
        frame1.setLocationRelativeTo(null);
        frame2.setLocation(frame1.getX() + 50, frame1.getY());
        w.setLocation(frame1.getX(), frame1.getY() - 50);
        frame2.setVisible(true);
    }
}

Comments
EVALUATION It was decided to fix this problem for Swing popups only and implement it as a part of the CR 6178004
18-04-2006

EVALUATION MSDN says that: <<If the created window is a top-level window, its default position is at the top of the Z-order (but beneath all topmost windows unless the created window is itself topmost).>> Applying to the testcase in question it means that the owned window is placed at the top of its owner (frame1) and at the top of the frame2. But I guess the system also replaces the owner in the z-order line. So, frame1 becomes one level lower than its owned window, but higher than frame2. Spying native message confirmed this thoughts. The owned window is getting WM_WINDOWPOSCHANGED and then its owner (frame1) is immediately getting the same message.
30-03-2006