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

modal dialog problems on multi head non-xinerama

    XMLWordPrintable

    Details

    • Subcomponent:
    • Introduced In Build:
      b38
    • Introduced In Version:
      6
    • Resolved In Build:
      b93
    • CPU:
      x86
    • OS:
      linux

      Description

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

      ADDITIONAL OS VERSION INFORMATION :
      Red Hat Linux Fedora Core 4: custom 2.6.16 kernel x86_64
      Solaris 8


      EXTRA RELEVANT SYSTEM CONFIGURATION :
      non-xinerama multiple head X-windows system

      A DESCRIPTION OF THE PROBLEM :
      When using multiple screens within one application, awt gets confused about which window should receive focus when using modal dialogs.

      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      Compile & run the attached program.

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      Pressing "Open Dialog" should open a dialog with one button ("Close") on any screen. Pressing "Close" should close the dialog, and allow one to press "Open Dialog" again.
      ACTUAL -
      Only on the primary screen does the "Close" button close the dialog. On the secondary (I only have 2 screens) screen pressing the "Close" button brings the original JFrame on top of the dialog rather than closing the dialog. As long as "Close" is pressed somewhere within the boundaries of the original JFrame, that JFrame is brought forward (even though it doesn't get focus). If the dialog is moved away from the JFrame and "Close" is pressed, it works properly.

      Note that on some window managers it isn't possible to get to the JDialog hiding behind the JFrame when this happens. As a result, the user has an unresposive desktop until the Java process is killed. On Solaris 8 using dtwm, things can get really nasty (even killing the Java app doesn't necessarily put things right).


      REPRODUCIBILITY :
      This bug can be reproduced always.

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

      public class TestCase {
              public TestCase() {
                      GraphicsEnvironment ge = GraphicsEnvironment.getLocalGraphicsEnvironment();
                      GraphicsDevice[] gs = ge.getScreenDevices();

                      if (gs.length<2) {
                              System.out.println("Not multi-head environment, test not valid!");
                              System.exit(1);
                      }

                      for (int i=0; i<gs.length; i++) {
                              JFrame frame=new JFrame("Frame "+i,gs[i].getDefaultConfiguration());
                              JButton button=new JButton("Open Dialog");
                              button.setMinimumSize(new Dimension(200,100));
                              button.setPreferredSize(new Dimension(200,100));
                              button.setSize(new Dimension(200,100));
                              button.addActionListener(new ButtonActionListener(frame,new TestDialog(frame,"Dialog #"+i,true,gs[i].getDefaultConfiguration())));
                              frame.getContentPane().add(button);
                              frame.pack();
                              frame.show();
                      }
              }
              private static class ButtonActionListener implements ActionListener {
                      JFrame frame;
                      JDialog dialog;
                      public ButtonActionListener(JFrame frame,JDialog dialog) {
                              super();
                              this.frame=frame;
                              this.dialog=dialog;
                      }
                      public void actionPerformed(ActionEvent e) {
                              dialog.setLocationRelativeTo(frame);
                              dialog.show();
                      }
              }
              public static class TestDialog extends JDialog {
                      public TestDialog(Frame owner,String title, boolean modal, GraphicsConfiguration gc) {
                              super(owner,title,modal,gc);
                              JButton button=new JButton("Close");
                              button.addActionListener(new ActionListener() {
                                      public void actionPerformed(ActionEvent e) {
                                              dispose();
                                      }
                              });
                              getContentPane().add(button);
                              pack();
                      }
              }
              public static void main(String args[]) {
                      new TestCase();
              }
      }

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

      CUSTOMER SUBMITTED WORKAROUND :
      Use an older version of the JVM (<1.6)

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              anthony Anthony Petrov (Inactive)
              Reporter:
              rmandalasunw Ranjith Mandala (Inactive)
              Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved:
                Imported:
                Indexed: