JDK-5061077 : Exception with JFileChooser in GTK LNF
  • Type: Bug
  • Component: client-libs
  • Sub-Component: javax.swing
  • Affected Version: 5.0
  • Priority: P2
  • Status: Resolved
  • Resolution: Fixed
  • OS: generic,solaris_9
  • CPU: generic,sparc
  • Submitted: 2004-06-10
  • Updated: 2004-10-25
  • Resolved: 2004-09-22
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
Other JDK 6
5.0u1 betaFixed 6Fixed
Related Reports
Duplicate :  
Relates :  
Relates :  
Relates :  
Description
JFileChooser in GTK Look and feel throws ArrayIndexOutOfBounds exception when space bar key is pressed on file list panel. 

Using keyboard navigation, filelist panel can gain focus. The user can select a folder and go inside the folder by pressing enter key. After that, user can't select any folder - on pressing any of the keys. If the space bar is pressed when the focus is on filelist panel, the following exception can be seen at the console:

Exception occurred during event dispatching:
java.lang.ArrayIndexOutOfBoundsException: 12 >= 7
	at java.util.Vector.elementAt(Vector.java:432)
	at com.sun.java.swing.plaf.gtk.GTKFileChooserUI$GTKDirectoryListModel.getElementAt(GTKFileChooserUI.java:760)
	at javax.swing.JList.getSelectedValue(JList.java:1814)
	at com.sun.java.swing.plaf.gtk.GTKFileChooserUI$SelectionListener.valueChanged(GTKFileChooserUI.java:361)
	at javax.swing.JList.fireSelectionValueChanged(JList.java:1317)
	at javax.swing.JList$ListSelectionHandler.valueChanged(JList.java:1331)
	at javax.swing.DefaultListSelectionModel.fireValueChanged(DefaultListSelectionModel.java:187)
	at javax.swing.DefaultListSelectionModel.fireValueChanged(DefaultListSelectionModel.java:157)
	at javax.swing.DefaultListSelectionModel.setValueIsAdjusting(DefaultListSelectionModel.java:619)
	at javax.swing.JList.setValueIsAdjusting(JList.java:1671)
	at javax.swing.plaf.basic.BasicListUI$Actions.actionPerformed(BasicListUI.java:1690)
	at javax.swing.SwingUtilities.notifyAction(SwingUtilities.java:1569)
	at javax.swing.JComponent.processKeyBinding(JComponent.java:2689)
	at javax.swing.JComponent.processKeyBindings(JComponent.java:2724)
	at javax.swing.JComponent.processKeyEvent(JComponent.java:2652)
	at java.awt.Component.processEvent(Component.java:5240)
	at java.awt.Container.processEvent(Container.java:1961)
	at java.awt.Component.dispatchEventImpl(Component.java:3931)
	at java.awt.Container.dispatchEventImpl(Container.java:2019)
	at java.awt.Component.dispatchEvent(Component.java:3779)
	at java.awt.KeyboardFocusManager.redispatchEvent(KeyboardFocusManager.java:1804)
	at java.awt.DefaultKeyboardFocusManager.dispatchKeyEvent(DefaultKeyboardFocusManager.java:668)
	at java.awt.DefaultKeyboardFocusManager.preDispatchKeyEvent(DefaultKeyboardFocusManager.java:916)
	at java.awt.DefaultKeyboardFocusManager.typeAheadAssertions(DefaultKeyboardFocusManager.java:794)
	at java.awt.DefaultKeyboardFocusManager.dispatchEvent(DefaultKeyboardFocusManager.java:632)
	at java.awt.Component.dispatchEventImpl(Component.java:3817)
	at java.awt.Container.dispatchEventImpl(Container.java:2019)
	at java.awt.Window.dispatchEventImpl(Window.java:1757)
	at java.awt.Component.dispatchEvent(Component.java:3779)
	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.pumpEventsForHierarchy(EventDispatchThread.java:153)
	at java.awt.Dialog+1.run(Dialog.java:514)
	at java.awt.Dialog.show(Dialog.java:535)
	at javax.swing.JFileChooser.showDialog(JFileChooser.java:717)
	at javax.swing.JFileChooser.showOpenDialog(JFileChooser.java:620)
	at FileChooserDemo$2.actionPerformed(FileChooserDemo.java:156)
	at javax.swing.AbstractButton.fireActionPerformed(AbstractButton.java:1834)
	at javax.swing.AbstractButton$Handler.actionPerformed(AbstractButton.java:2152)
	at javax.swing.DefaultButtonModel.fireActionPerformed(DefaultButtonModel.java:420)
	at javax.swing.DefaultButtonModel.setPressed(DefaultButtonModel.java:258)
	at javax.swing.plaf.basic.BasicButtonListener.mouseReleased(BasicButtonListener.java:234)
	at java.awt.Component.processMouseEvent(Component.java:5463)
	at javax.swing.JComponent.processMouseEvent(JComponent.java:3052)
	at java.awt.Component.processEvent(Component.java:5228)
	at java.awt.Container.processEvent(Container.java:1961)
	at java.awt.Component.dispatchEventImpl(Component.java:3931)
	at java.awt.Container.dispatchEventImpl(Container.java:2019)
	at java.awt.Component.dispatchEvent(Component.java:3779)
	at java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:4203)
	at java.awt.LightweightDispatcher.processMouseEvent(Container.java:3883)
	at java.awt.LightweightDispatcher.dispatchEvent(Container.java:3813)
	at java.awt.Container.dispatchEventImpl(Container.java:2005)
	at java.awt.Window.dispatc

The exception occurs on all platforms. I was able to reproduce it on b32 and b51. It does not occur on b09.

Steps to reproduce:
1. In SwingSet2 demo, switch to GTK L&F
2. Go to FileChooser demo and open the filechooser.
3. Using keyboard, bring the focus to filelist panel, select a folder and press enter.
4. Now press the space key. The exception occurs now.


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

Step three can also be:

3. Double-click on an empty directory.

(More specifically, a directory with fewer children than the index
of the directory in its parent's list).

###@###.### 2004-06-10

Comments
CONVERTED DATA BugTraq+ Release Management Values COMMIT TO FIX: 1.5.0_01 mustang FIXED IN: 1.5.0_01 mustang INTEGRATED IN: 1.5.0_01 mustang
28-09-2004

EVALUATION This is probably related to the issue in bug 5036904 where an initial selection or lead/anchor placement is not done when changing directories. ###@###.### 2004-06-10 Name: ke153230 Date: 09/06/2004 We do not reset selection index when we call clearSelection() in motif and GTK LaFs. This leads to situations when during directory navigation we go to a subfolder which has less files than the index its folder has in parent folder. We get this exception if we do not reset selection index and do not see the currently selected index. Fix corrects this by resetting the selection index after call to clear selection. ======================================================================
28-09-2004

WORK AROUND Name: ke153230 Date: 09/06/2004 To be able to navigate via keyboard, press Home button. ======================================================================
28-09-2004

SUGGESTED FIX Name: ke153230 Date: 09/06/2004 *** /net/crown/export1/kve/dragon/webrev/src/share/classes/com/sun/java/swing/plaf/gtk/GTKFileChooserUI.java- �������� ��M-^X�������� 25 18:12:02 2004 --- GTKFileChooserUI.java �������� ��M-^X�������� 25 18:09:10 2004 *************** *** 243,249 **** --- 243,259 ---- protected void doDirectoryChanged(PropertyChangeEvent e) { directoryList.clearSelection(); + ListSelectionModel sm = directoryList.getSelectionModel(); + if (sm instanceof DefaultListSelectionModel) { + ((DefaultListSelectionModel)sm).moveLeadSelectionIndex(0); + ((DefaultListSelectionModel)sm).setAnchorSelectionIndex(0); + } fileList.clearSelection(); + sm = fileList.getSelectionModel(); + if (sm instanceof DefaultListSelectionModel) { + ((DefaultListSelectionModel)sm).moveLeadSelectionIndex(0); + ((DefaultListSelectionModel)sm).setAnchorSelectionIndex(0); + } File currentDirectory = getFileChooser().getCurrentDirectory(); if (currentDirectory != null) { *************** *** 1159,1165 **** } if (getFileChooser().getCurrentDirectory().equals(dir)) { directoryList.clearSelection(); ! rescanCurrentDirectory(getFileChooser()); return; } } --- 1169,1181 ---- } if (getFileChooser().getCurrentDirectory().equals(dir)) { directoryList.clearSelection(); ! fileList.clearSelection(); ! ListSelectionModel sm = fileList.getSelectionModel(); ! if (sm instanceof DefaultListSelectionModel) { ! ((DefaultListSelectionModel)sm).moveLeadSelectionIndex(0); ! ((DefaultListSelectionModel)sm).setAnchorSelectionIndex(0); ! } ! rescanCurrentDirectory(getFileChooser()); return; } } *** /net/crown/export1/kve/dragon/webrev/src/share/classes/com/sun/java/swing/plaf/motif/MotifFileChooserUI.java- �������� ��M-^X�������� 25 18:12:03 2004 --- MotifFileChooserUI.java �������� ��M-^X�������� 20 19:46:54 2004 *************** *** 156,162 **** --- 156,172 ---- } } else if(prop.equals(JFileChooser.DIRECTORY_CHANGED_PROPERTY)) { directoryList.clearSelection(); + ListSelectionModel sm = directoryList.getSelectionModel(); + if (sm instanceof DefaultListSelectionModel) { + ((DefaultListSelectionModel)sm).moveLeadSelectionIndex(0); + ((DefaultListSelectionModel)sm).setAnchorSelectionIndex(0); + } fileList.clearSelection(); + sm = fileList.getSelectionModel(); + if (sm instanceof DefaultListSelectionModel) { + ((DefaultListSelectionModel)sm).moveLeadSelectionIndex(0); + ((DefaultListSelectionModel)sm).setAnchorSelectionIndex(0); + } File currentDirectory = getFileChooser().getCurrentDirectory(); if(currentDirectory != null) { try { ======================================================================
28-09-2004