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

XToolkit: List throws ArrayIndexOutOfBoundsException on double clicking when the List is empty

XMLWordPrintable

    • b89
    • generic
    • generic
    • Verified

      This occurs with XToolkit from tiger onwards.

      I've a List which has couple of items in it. After removing the items, if the List is double clicked, it throws the following Exception:

      Exception in thread "AWT-EventQueue-0" java.lang.ArrayIndexOutOfBoundsException: 0 >= 0
              at java.util.Vector.elementAt(Vector.java:432)
              at sun.awt.X11.XListPeer.mouseReleased(XListPeer.java:604)
              at sun.awt.X11.XListPeer.handleJavaMouseEvent(XListPeer.java:525)
              at sun.awt.X11.XComponentPeer.handleEvent(XComponentPeer.java:611)
              at java.awt.Component.dispatchEventImpl(Component.java:4031)
              at java.awt.Component.dispatchEvent(Component.java:3803)
              at java.awt.EventQueue.dispatchEvent(EventQueue.java:463)
              at java.awt.EventDispatchThread.pumpOneEventForHierarchy(EventDispatchThread.java:234)
              at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:163)
              at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:157) at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:149) at java.awt.EventDispatchThread.run(EventDispatchThread.java:110)


      To reproduce, run the following testcase:

      import java.awt.*;
      import java.awt.event.*;

      public class ListTest {

          private static List list;

          public static void main(String[] args) {
              Frame f = new Frame();
              f.setLayout(new FlowLayout());
              list = new List();
              list.add("list1");
              list.add("list2");
              f.add(list);
              Button b = new Button("Remove");
              b.addActionListener(new ActionListener() {
                  public void actionPerformed(ActionEvent event) {
                      for (int i = 0; i < list.getSelectedIndexes().length; i++) {
                          list.remove(list.getSelectedIndexes()[i]);
                      }
                  }
              });
              f.add(b);
              f.setSize(200, 200);
              f.setVisible(true);
          }
      }

      The testcase shows a List with two items and a 'Remove' button. Select each item and click the 'Remove' button to remove them. After removing both the items, double click inside the List. If the exception is thrown, bug is reproduced.

            dcherepanov Dmitry Cherepanov
            gramachasunw Girish Ramachandran (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: