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

Submenu is shown on wrong screen in multiple monitor environment

XMLWordPrintable

    • b17
    • x86
    • windows_xp

      FULL PRODUCT VERSION :
      java version "1.5.0_05"
      Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0_05-b05)
      Java HotSpot(TM) Client VM (build 1.5.0_05-b05, mixed mode)

      The problem can also be reproduced on latest (to date) Mustang snapshot:
      java version "1.6.0-beta2"
      Java(TM) 2 Runtime Environment, Standard Edition (build 1.6.0-beta2-b74)
      Java HotSpot(TM) Client VM (build 1.6.0-beta2-b74, mixed mode, sharing)

      ADDITIONAL OS VERSION INFORMATION :
      Microsoft Windows XP [Version 5.1.2600]

      EXTRA RELEVANT SYSTEM CONFIGURATION :
      Dual screen system.
      Primary screen 1600x1280
      Secondary screen 1280x1024
      Secondary screen configured on top of primary screen, left edges aligned

      A DESCRIPTION OF THE PROBLEM :
      In some cases if some menu has a submenu that submenu shows up on a wrong screen i.e. main menu is shown on a primary display and submenu shows up on a secondary display so it's tricky to select items from the submenu using mouse.

      There are similar bugs entered like 4367577 but those were reported against 1.3 version and closed as fixed, while behavior is still reproducible under 1.5 and 1.6 beta.

      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      Setup displays as described in configuration section
      Compile and run the java class attached.
      Move small frame that appears to the primary (lower) screen bottom left corner.
      Click on the text in the frame.
      In a popup menu that appears hover items with the mouse so submenus show up.

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      Submenu should always show up on the same screen root menu have been shown.
      ACTUAL -
      Some of the submenus show up on secondary screen. If screen resolutions are exactly like mine then items 0-3 show up on wrong display while others are displayed correctly.

      REPRODUCIBILITY :
      This bug can be reproduced always.

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

      public class PopupMenuTest {
          public static void main(String[] args) {
              JFrame frame = new JFrame();
              final JTextArea content = new JTextArea("Some text goes here");
              content.addMouseListener(new MouseAdapter() {
                  public void mouseClicked(MouseEvent e) {
                      JPopupMenu menu = new JPopupMenu();
                      for (int i = 0; i < 20; i++) {
                          menu.add(generateSubMenu("main menu item number " + i));
                      }
                      menu.show(content, e.getX(), e.getY());
                  }
              });
              frame.getContentPane().add(content);
              frame.pack();
              frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
              frame.setVisible(true);
          }

          private static JMenu generateSubMenu(String name) {
              JMenu menu = new JMenu(name);
              for (int i = 0; i < 40; i++) {
                  menu.add(new JMenuItem("item that should have name long enough: " + i));
              }
              return menu;
          }
      }

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

      CUSTOMER SUBMITTED WORKAROUND :
      None known

            avu Alexey Ushakov
            ndcosta Nelson Dcosta (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: