JDK-4246027 : Click drag on JPopupMenu eventually generate ArrayIndexOutOfBoundsException
  • Type: Bug
  • Component: client-libs
  • Sub-Component: javax.swing
  • Affected Version: 1.2.2
  • Priority: P4
  • Status: Closed
  • Resolution: Duplicate
  • OS: windows_95
  • CPU: x86
  • Submitted: 1999-06-11
  • Updated: 2000-07-14
  • Resolved: 2000-07-14
Related Reports
Duplicate :  
Description

Name: skT88420			Date: 06/11/99


Click-drag to show the JPopupMenu and drag into the popup menu.  Continue to hold down the mouse button and drag in and out of the menu.  Eventually you will have the ArrayIndexOutOfBOundsException.
Exception occurred during event dispatching:

java.lang.ArrayIndexOutOfBoundsException

	at javax.swing.MenuSelectionManager.processMouseEvent(MenuSelectionManager.java:237)

	at javax.swing.plaf.basic.BasicPopupMenuUI$MouseGrabber.mouseDragged(BasicPopupMenuUI.java:311)

	at java.awt.Component.processMouseMotionEvent(Component.java:3190)

	at javax.swing.JComponent.processMouseMotionEvent(JComponent.java:1852)

	at java.awt.Component.processEvent(Component.java:2989)

	at java.awt.Container.processEvent(Container.java:991)

	at java.awt.Component.dispatchEventImpl(Component.java:2380)

	at java.awt.Container.dispatchEventImpl(Container.java:1036)

	at java.awt.Component.dispatchEvent(Component.java:2293)

	at java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:2039)

	at java.awt.LightweightDispatcher.processMouseEvent(Container.java:1805)

	at java.awt.LightweightDispatcher.dispatchEvent(Container.java:1719)

	at java.awt.Container.dispatchEventImpl(Container.java:1023)

	at java.awt.Window.dispatchEventImpl(Window.java:749)

	at java.awt.Component.dispatchEvent(Component.java:2293)

	at java.awt.EventQueue.dispatchEvent(EventQueue.java:275)

	at java.awt.EventDispatchThread.pumpOneEvent(EventDispatchThread.java:96)

	at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:87)

	at java.awt.EventDispatchThread.run(EventDispatchThread.java:78)


No exception if click-release to bring up the JPopupMenu.


import java.awt.*;
import java.awt.event.*;
import javax.swing.*;


public class JPopupAOOBBug extends JFrame {

  public JPopupAOOBBug() {
    super("JPopup Drag Bug");  
    
    JLabel label = new JLabel("Popup Here");
    getContentPane().add(label);
    final JPopupMenu menu = new JPopupMenu();
    menu.add("Group1");
    menu.add("Group2");
    
    label.addMouseListener(new MouseAdapter() {
        public void mousePressed(MouseEvent event) {
            menu.show(event.getComponent(), event.getX(), event.getY());
        }
    });


    
    setSize(300, 100);
    setVisible(true);
  }
  

  public static void main (String args[]) {
    JPopupAOOBBug frame = new JPopupAOOBBug();
    frame.addWindowListener(new WindowAdapter() {
      public void windowClosing(WindowEvent e) {
        System.exit(0);
      }
    });
  }
  
    
  
}
(Review ID: 84265) 
======================================================================

Comments
EVALUATION I can't get this to happen on Solaris -- may be Windows only... georges.saab@Eng 1999-10-12 Name: apR10133 Date: 07/12/2000 This bug was introduced with fix for 4188027 in class javax.swing.plaf.basic.BasicMenuItenUI.java. The cause of this bug is in state of mouse event modifiers. When mouse enter/exit frame the mouse enter/exit event always generated without modifier. When we drag mouse out of the popup menu and frame we can receive a mouse event without modifier and we incorrectly changes selected path. ###@###.### ====================================================================== Name: apR10133 Date: 07/13/2000 I've submited a bug 4352790 against AWT. The current Swing bug is result of above one. ###@###.### ======================================================================
11-06-2004

WORK AROUND Name: skT88420 Date: 06/11/99 Don't show the menu in mousePressed(), show in MouseRelease() instead. ======================================================================
11-06-2004