On Thu, 1 Sep 2022 06:40:08 GMT, Tejesh R <[email protected]> wrote:
>> JFileChooser.getSelectedFiles() failed to retrieve files with
>> multi-selection and double-click. This occurs when a single file is selected
>> then enable multi-selection then select the same file through mouse
>> double-click(Two file chooser dialogs used before and after multi-selection
>> enabled). SelectedFiles are updated when a change in files/directory
>> selection is done or when selection is made through keyboard selection. In
>> this case since a single file is selected before multi-selection is enabled
>> and same file is selected again without changing the selection
>> index/directory, leaving selected Files un-updated.
>> **Proposed Fix** : Whenever Multi-Selection is enabled check if any files
>> are selected, if yes update the selected Files of JFileChoooser.
>
> Tejesh R has updated the pull request incrementally with one additional
> commit since the last revision:
>
> Updated based on review comments
src/java.desktop/share/classes/sun/swing/FilePane.java line 1763:
> 1761: selectedFiles = getFileChooser().getSelectedFiles();
> 1762: } else if (getFileChooser().getSelectedFile() != null) {
> 1763: File selectedFile = getFileChooser().getSelectedFile();
File selectedFile = getFileChooser().getSelectedFile();
selectedFiles = new File[1];
selectedFiles[0] = selectedFile;
You can directly assign getFileChooser().getSelectedFile() value to
selectedFiles[0]. I think no need to create extra selectedFile variable.
-------------
PR: https://git.openjdk.org/jdk/pull/9996