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

[macosx] A JDialog appears on wrong place when using dual display on Mac

XMLWordPrintable

    • x86
    • os_x

      FULL PRODUCT VERSION :
      Java(TM) SE Runtime Environment (build 1.7.0_05-b05)
      Java HotSpot(TM) 64-Bit Server VM (build 23.1-b03, mixed mode)

      ADDITIONAL OS VERSION INFORMATION :
      Mac OS X 10.7.4

      A DESCRIPTION OF THE PROBLEM :
      The default position of JDialog is wrong when I use 2 displays on Mac OS X.
      It appears on top right of the second dsiplay every time.
      It appears on left end of second display if the parent JFrame is on the first display and JDialog#setLocationRelativeTo is called.

      REGRESSION. Last worked in version 7

      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      1,Execute a class I appended on a Mac with 2 displays and Java7.

      java test.DialogTest

      2,Move the window anywhere you want and push the button on the window.

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      A dialog appears on the same place of the window.
      ACTUAL -
      A dialog appears second display even the parent window is on the first display.

      REPRODUCIBILITY :
      This bug can be reproduced always.

      ---------- BEGIN SOURCE ----------
      package test;

      import java.awt.event.ActionEvent;
      import java.awt.event.ActionListener;

      import javax.swing.JButton;
      import javax.swing.JDialog;
      import javax.swing.JFrame;
      import javax.swing.JLabel;

      public class DialogTest extends JFrame {
      public DialogTest() {
      JButton button = new JButton("go");
      button.addActionListener(new ActionListener() {

      @Override
      public void actionPerformed(ActionEvent arg0) {
      JDialog dialog = new JDialog(DialogTest.this, true);
      dialog.getContentPane().add(new JLabel("test"));
      dialog.pack();
      dialog.setLocationRelativeTo(DialogTest.this);
      dialog.setVisible(true);
      }
      });

      getContentPane().add(button);
      }

      public static void main(String[] args) {
      DialogTest dialogTest = new DialogTest();
      dialogTest.pack();
      dialogTest.setVisible(true);
      }
      }

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

            kizune Alexander Zuev
            webbuggrp Webbug Group
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: