Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-6613040

Showing modal JDialogs causes all JFrames to come to the front of native windows

    XMLWordPrintable

Details

    • Bug
    • Resolution: Unresolved
    • P3
    • None
    • 6
    • client-libs
    • x86
    • linux

    Description

      FULL PRODUCT VERSION :
      java version "1.6.0_03"
      Java(TM) SE Runtime Environment (build 1.6.0_03-b05)
      Java HotSpot(TM) 64-Bit Server VM (build 1.6.0_03-b05, mixed mode)


      ADDITIONAL OS VERSION INFORMATION :
      Linux macdonaldjlinux 2.6.11.4-20a-smp #1 SMP Wed Mar 23 21:52:37 UTC 2005 x86_6
      4 x86_64 x86_64 GNU/Linux

      A DESCRIPTION OF THE PROBLEM :
      When you show a modal JDialog in a Java application on Linux, it causes all the other JFrames (not just the parent JFrame) to appear in front of native windows. For example (ascii art):

      +--------------+
      | jframe1 |
      | +---------------+
      +-| native window |
        | |
        +---------------+
        
      +--------------+
      | jframe2 |
      | |
      +--------------+

      If you launch a modal JDialog from JFrame2, then JFrame1 will pop in front of the native window. This is incorrect -- JFrame1 should stay where it was. This did not occur with Java 1.5.

      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      Run the attached program, DialogTest, using Java 1.6, on Linux (doesn't occur on Windows).

      Two frames will appear, Test1 and Test2. Place Test1 behind a native window (e.g., a terminal window). Now click on the button in Test2. This will launch a modal dialog.

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      The frame "Test1" should remain behind the native window.
      ACTUAL -
      The frame "Test1" pops in front of the native window.

      REPRODUCIBILITY :
      This bug can be reproduced always.

      ---------- BEGIN SOURCE ----------
      import java.awt.*;
      import java.awt.event.*;
      import javax.swing.*;
      import javax.swing.event.*;

      public class DialogTest
      {
         public static void main(String[] args)
         {
             JFrame f = new JFrame("Test1");
             f.addWindowListener(new WindowListener() {
                     public void windowActivated(WindowEvent e) {
                         System.out.println("windowActivated(" + e + ")");
                     }
                     public void windowClosed(WindowEvent e) {
                         System.out.println("windowClosed(" + e + ")");
                     }
                     public void windowClosing(WindowEvent e) {
                         System.out.println("windowClosing(" + e + ")");
                     }
                     public void windowDeactivated(WindowEvent e) {
                         System.out.println("windowDeactivated(" + e + ")");
                     }
                     public void windowDeiconified(WindowEvent e) {
                         System.out.println("windowDeiconified(" + e + ")");
                     }
                     public void windowIconified(WindowEvent e) {
                         System.out.println("windowIconified(" + e + ")");
                     }
                     public void windowOpened(WindowEvent e) {
                         System.out.println("windowOpened(" + e + ")");
                     }
                 });
             f.setSize(300, 200);
             f.show();

             final JFrame f2 = new JFrame("Test2");
             f2.getContentPane().add(new JButton(new AbstractAction("Push Me") {
                     public void actionPerformed(ActionEvent e) {
                         JDialog d = new JDialog(f2, true);
                         d.show();
                     }
                 }));
             f2.setSize(300, 200);
             f2.setLocationRelativeTo(null);
             f2.show();
             
         }
      }

      ---------- END SOURCE ----------

      CUSTOMER SUBMITTED WORKAROUND :
      Use Java 1.5; make dialogs non-modal; have not tested alternate window managers.

      Attachments

        Activity

          People

            art Artem Ananiev (Inactive)
            ndcosta Nelson Dcosta (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Imported:
              Indexed: