From 721264460ada4f9e32f01fc3da5ed014bb6a4706 Mon Sep 17 00:00:00 2001 From: Alexander Scherbatiy Date: Wed, 17 Oct 2012 17:33:26 +0400 Subject: [PATCH] 8000969: [macosx] Directories are not deselected when JFileChooser has FILES_ONLY selection mode Reviewed-by: rupashka --- .../classes/com/apple/laf/AquaFileChooserUI.java | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/jdk/src/macosx/classes/com/apple/laf/AquaFileChooserUI.java b/jdk/src/macosx/classes/com/apple/laf/AquaFileChooserUI.java index f5dba5bd1c5..b7598f99d6d 100644 --- a/jdk/src/macosx/classes/com/apple/laf/AquaFileChooserUI.java +++ b/jdk/src/macosx/classes/com/apple/laf/AquaFileChooserUI.java @@ -379,6 +379,19 @@ public class AquaFileChooserUI extends FileChooserUI { } } updateButtonState(getFileChooser()); + } else if (prop.equals(JFileChooser.SELECTED_FILES_CHANGED_PROPERTY)) { + JFileChooser fileChooser = getFileChooser(); + if (!fileChooser.isDirectorySelectionEnabled()) { + final File[] files = (File[]) e.getNewValue(); + if (files != null) { + for (int selectedRow : fFileList.getSelectedRows()) { + File file = (File) fFileList.getValueAt(selectedRow, 0); + if (fileChooser.isTraversable(file)) { + fFileList.removeSelectedIndex(selectedRow); + } + } + } + } } else if (prop.equals(JFileChooser.DIRECTORY_CHANGED_PROPERTY)) { fFileList.clearSelection(); final File currentDirectory = getFileChooser().getCurrentDirectory();