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

JMenuBar popup menus appear on wrong monitor when monitor added after startup

    XMLWordPrintable

    Details

      Description

      FULL PRODUCT VERSION :
      java version "1.5.0_09"
      Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0_09-b03)
      Java HotSpot(TM) Client VM (build 1.5.0_09-b03, mixed mode)
      Java(TM) SE Runtime Environment (build 1.6.0-b105).

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

      EXTRA RELEVANT SYSTEM CONFIGURATION :
      Dual monitor system

      A DESCRIPTION OF THE PROBLEM :
      JMenuBar menu always pops up on the primary monitor, when the frame is on the secondary monitor and this monitor was enabled after the frame was created (after application startup).

      More information: Problem is reproducible under the latest release:
      Java(TM) SE Runtime Environment (build 1.6.0-b105). When enabling the secondary monitor (while the application is running) and moving the Swing application window to the secondary monitor,

      1) The JMenuBar's popup menu still appears on the wrong monitor.
      2) The following uncaught exception is printed to the console:
      Exception in thread "AWT-EventQueue-0"
      java.lang.ArrayIndexOutOfBoundsException: 1
      at sun.awt.windows.WWindowPeer.updateGC(WWindowPeer.java:371)
      at sun.awt.windows.WWindowPeer.displayChanged(WWindowPeer.java:398)
      at sun.awt.windows.WWindowPeer$1.run(WWindowPeer.java:350)
      at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:209)
      at java.awt.EventQueue.dispatchEvent(EventQueue.java:597)
      at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread. java:273)
      at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.jav
      a:183)
      at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.
      java:173)
      at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:168)
      at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:160)
      at java.awt.EventDispatchThread.run(EventDispatchThread.java:121)

      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      1. On a dual-monitor system, disable the secondary monitor.
      2. Start a Java/Swing application with a menu bar.
      3. Re-enable the secondary monitor.
      4. Move the application window to the secondary monitor.
      5. Click on the menu.

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      The menu should pop up on the secondary monitor, below the JMenuBar in the application's frame.
      ACTUAL -
      The menu pops up on the primary monitor, even though the application's window is on the secondary monitor.

      REPRODUCIBILITY :
      This bug can be reproduced always.

      ---------- BEGIN SOURCE ----------
      import javax.swing.JFrame;
      import javax.swing.JMenu;
      import javax.swing.JMenuBar;
      import javax.swing.JMenuItem;

      /*
       * Test application for a bug report.
       * This app is a stripped-down version of the MenuLookDemo
       * sample in the Swing tutorials on java.sun.com.
       */
      public class MenuDemo {

          public JMenuBar createMenuBar() {
              JMenuBar menuBar;
              JMenu menu;
              JMenuItem menuItem;

              menuBar = new JMenuBar();
              menu = new JMenu("A Menu");
              menuBar.add(menu);

              menuItem = new JMenuItem("A menu item");
              menu.add(menuItem);
              return menuBar;
          }

          private static void createAndShowGUI() {
              //Create and set up the window.
              JFrame frame = new JFrame("MenuLookDemo");
              frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

              //Create and set up the content pane.
              MenuDemo demo = new MenuDemo();
              frame.setJMenuBar(demo.createMenuBar());

              //Display the window.
              frame.setSize(450, 260);
              frame.setVisible(true);
          }

          public static void main(String[] args) {
              javax.swing.SwingUtilities.invokeLater(new Runnable() {
                  public void run() {
                      createAndShowGUI();
                  }
              });
          }
      }

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

        Attachments

          Issue Links

            Activity

              People

              Assignee:
              mlapshin Mikhail Lapshin (Inactive)
              Reporter:
              ndcosta Nelson Dcosta (Inactive)
              Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

                Dates

                Created:
                Updated:
                Resolved:
                Imported:
                Indexed: