Name: rmT116609 Date: 10/08/2002
FULL PRODUCT VERSION :
java version "1.4.1"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.1-b21)
Java HotSpot(TM) Client VM (build 1.4.1-b21, mixed mode)
FULL OPERATING SYSTEM VERSION :
Windows NT Version 4.0
Windows 2000
A DESCRIPTION OF THE PROBLEM :
JFileChooser.rescanCurrentDirectory() crashes with an
ArrayIndexOutOfBoundsException if multiple selection is on
and the last selected file has been deleted (externally).
My example code calls rescanCurrentDirectory() with the
JFileChooser not visible, but the same error occurs if
it is visible.
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
1. Compile and run source code.
2. Select the last two files in any directory.
3. Externally delete the last file in the directory.
4. Cancel the dialog.
EXPECTED VERSUS ACTUAL BEHAVIOR :
Expect nothing (visible) to happen. Instead there is
an ArrayIndexOutOfBounds exception thrown.
ERROR MESSAGES/STACK TRACES THAT OCCUR :
java.lang.ArrayIndexOutOfBoundsException: Array index out of range: 18
at java.util.Vector.get(Vector.java:713)
at javax.swing.plaf.basic.BasicDirectoryModel.getElementAt
(BasicDirectoryModel.java:143)
at javax.swing.JList.getSelectedValues(JList.java:1776)
at javax.swing.plaf.metal.MetalFileChooserUI.setFileSelected
(MetalFileChooserUI.java:1200)
at javax.swing.plaf.metal.MetalFileChooserUI$DelayedSelectionUpdater.run
(MetalFileChooserUI.java:904)
at java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:178)
at java.awt.EventQueue.dispatchEvent(EventQueue.java:448)
at java.awt.EventDispatchThread.pumpOneEventForHierarchy
(EventDispatchThread.java:197)
at java.awt.EventDispatchThread.pumpEventsForHierarchy
(EventDispatchThread.java:150)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:144)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:136)
at java.awt.EventDispatchThread.run(EventDispatchThread.java:99)
REPRODUCIBILITY :
This bug can be reproduced always.
---------- BEGIN SOURCE ----------
import javax.swing.*;
public class JFileChooserBug3 {
public static void main(String args[]) {
JFileChooser fc = new JFileChooser();
fc.setMultiSelectionEnabled(true);
fc.showOpenDialog(null);
fc.rescanCurrentDirectory();
}
}
---------- END SOURCE ----------
(Review ID: 165528)
======================================================================