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

Unexpected ArrayIndexOfBoundsException after JMenu.setSelected(true) call

    Details

    • Subcomponent:
    • Resolved In Build:
      beta2
    • CPU:
      x86
    • OS:
      linux
    • Verification:
      Verified

      Description



      Name: iaR10016 Date: 10/10/2000



      JDK version:
      java version "1.3.0"
      Java(TM) 2 Runtime Environment, Standard Edition (build 1.3.0)
      Java HotSpot(TM) Client VM (build 1.3.0, mixed mode)

      The following test example creates JFrame with JMenu component.
      To reproduce the bug please select menu and then try to select any menu item.

      The following error message appears unexpectedly when you move mouse to the item:

      ...

      $ java test
      Exception occurred during event dispatching:
      java.lang.ArrayIndexOutOfBoundsException
              at javax.swing.MenuSelectionManager.processMouseEvent(MenuSelectionManager.java:238)
              at javax.swing.plaf.basic.BasicMenuUI$MouseInputHandler.mouseDragged(BasicMenuUI.java:370)
              at java.awt.AWTEventMulticaster.mouseDragged(AWTEventMulticaster.java:260)
              at java.awt.Component.processMouseMotionEvent(Component.java:3761)
              at javax.swing.JComponent.processMouseMotionEvent(JComponent.java:2377)
              at java.awt.Component.processEvent(Component.java:3550)
              at java.awt.Container.processEvent(Container.java:1164)
              at java.awt.Component.dispatchEventImpl(Component.java:2595)
              at java.awt.Container.dispatchEventImpl(Container.java:1213)
              at java.awt.Component.dispatchEvent(Component.java:2499)
              at java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:2451)
              at java.awt.LightweightDispatcher.processMouseEvent(Container.java:2205)
              at java.awt.LightweightDispatcher.dispatchEvent(Container.java:2125)
              at java.awt.Container.dispatchEventImpl(Container.java:1200)
              at java.awt.Window.dispatchEventImpl(Window.java:912)
              at java.awt.Component.dispatchEvent(Component.java:2499)
              at java.awt.EventQueue.dispatchEvent(EventQueue.java:333)
              at java.awt.EventDispatchThread.pumpOneEvent(EventDispatchThread.java:103)
              at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:93)
              at java.awt.EventDispatchThread.run(EventDispatchThread.java:84)
      Exception occurred during event dispatching:
      java.lang.ArrayIndexOutOfBoundsException
              at javax.swing.MenuSelectionManager.processMouseEvent(MenuSelectionManager.java:238)
              at javax.swing.plaf.basic.BasicMenuUI$MouseInputHandler.mouseDragged(BasicMenuUI.java:370)
              at java.awt.AWTEventMulticaster.mouseDragged(AWTEventMulticaster.java:260)
              at java.awt.Component.processMouseMotionEvent(Component.java:3761)
              at javax.swing.JComponent.processMouseMotionEvent(JComponent.java:2377)
              at java.awt.Component.processEvent(Component.java:3550)
              at java.awt.Container.processEvent(Container.java:1164)
              at java.awt.Component.dispatchEventImpl(Component.java:2595)
              at java.awt.Container.dispatchEventImpl(Container.java:1213)
              at java.awt.Component.dispatchEvent(Component.java:2499)
              at java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:2451)
              at java.awt.LightweightDispatcher.processMouseEvent(Container.java:2205)
              at java.awt.LightweightDispatcher.dispatchEvent(Container.java:2125)
              at java.awt.Container.dispatchEventImpl(Container.java:1200)
              at java.awt.Window.dispatchEventImpl(Window.java:912)
              at java.awt.Component.dispatchEvent(Component.java:2499)
              at java.awt.EventQueue.dispatchEvent(EventQueue.java:333)
              at java.awt.EventDispatchThread.pumpOneEvent(EventDispatchThread.java:103)
              at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:93)
              at java.awt.EventDispatchThread.run(EventDispatchThread.java:84)
      Exception occurred during event dispatching:
      java.lang.ArrayIndexOutOfBoundsException
              at javax.swing.MenuSelectionManager.processMouseEvent(MenuSelectionManager.java:238)
              at javax.swing.plaf.basic.BasicMenuUI$MouseInputHandler.mouseDragged(BasicMenuUI.java:370)
              at java.awt.AWTEventMulticaster.mouseDragged(AWTEventMulticaster.java:260)
              at java.awt.Component.processMouseMotionEvent(Component.java:3761)
              at javax.swing.JComponent.processMouseMotionEvent(JComponent.java:2377)
              at java.awt.Component.processEvent(Component.java:3550)
              at java.awt.Container.processEvent(Container.java:1164)
              at java.awt.Component.dispatchEventImpl(Component.java:2595)
              at java.awt.Container.dispatchEventImpl(Container.java:1213)
              at java.awt.Component.dispatchEvent(Component.java:2499)
              at java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:2451)
              at java.awt.LightweightDispatcher.processMouseEvent(Container.java:2205)
              at java.awt.LightweightDispatcher.dispatchEvent(Container.java:2125)
              at java.awt.Container.dispatchEventImpl(Container.java:1200)
              at java.awt.Window.dispatchEventImpl(Window.java:912)
              at java.awt.Component.dispatchEvent(Component.java:2499)
              at java.awt.EventQueue.dispatchEvent(EventQueue.java:333)
              at java.awt.EventDispatchThread.pumpOneEvent(EventDispatchThread.java:103)
              at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:93)
              at java.awt.EventDispatchThread.run(EventDispatchThread.java:84)
      ...

      Please note that if the JMenu.setSelected(true) method call is commented, the test works fine.

      ------------------------- test.java ---------------------------------------------
      import java.awt.*;
      import javax.swing.*;

      public class test {
          public static void main (String [] args ) {
              JFrame frame = new JFrame();
              frame.setSize(new Dimension(200,300));
              JMenu menu = new JMenu("Menu");
              menu.add("Item 1");
              menu.add("Item 2");
              menu.add("Item 3");
              menu.setSelected(true);
              JMenuBar menuBar = new JMenuBar();
              menuBar.add(menu);
              frame.getContentPane().add( menuBar, BorderLayout.CENTER );
              frame.setVisible(true);
          }
      }

      ---------------------------------------------------------------------------------

      ======================================================================

        Attachments

          Activity

            People

            • Assignee:
              mdavidsosunw Mark Davidson (Inactive)
              Reporter:
              irasunw Ira Ira (Inactive)
            • Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:
                Imported:
                Indexed: