On Mon, 3 Oct 2022 11:28:09 GMT, Tejesh R <t...@openjdk.org> wrote:

>> src/java.desktop/share/classes/javax/swing/plaf/metal/MetalFileChooserUI.java
>>  line 1271:
>> 
>>> 1269:             File curDir = getFileChooser().getCurrentDirectory();
>>> 1270: 
>>> 1271:             if (curDir != null && !curDir.equals(f)) {
>> 
>> If `f` is always not null, you can you use `!f.equals(curDir)`.
>
>> 
> 
> Prevention of not setting to null means I have to modify `JFileChooser` class 
> itself, so just handling here. And yeah` f `can't be null, can do that.

Why is it bad to modify `JFileChooser` class itself?

I think setting the current directory to `null` while it displays a directory 
kind of breaks the invariant.

`JFileChooser` navigated to a directory and the current directory is set to it. 
You tried navigating to another directory, `FileSystem` didn't allow the 
navigation, so `JFileChooser` continues to display the files in the directory 
that is showed before. Thus, the current directory hasn't changed. From this 
point of view, the current directory should remain unchanged.

-------------

PR: https://git.openjdk.org/jdk/pull/10485

Reply via email to