RFR: 4365952: Cannot disable JFileChooser [v4]
Abhishek Kumar
abhiscxk at openjdk.org
Fri Oct 20 06:14:39 UTC 2023
On Fri, 20 Oct 2023 05:16:05 GMT, Tejesh R <tr at openjdk.org> wrote:
>> Invoking `setEnabled(false)` on an instance of `JFileChooser` the sub-components are unaffected since the sub-components didn't set/unset enabled explicitly. The fix address the issue and sets the Enabled flag to each sub-components. Along with setting the property to each sub components, the action listeners like mouseClick(Double too) and scroll actions has to be processed based on enabled/disabled property similar to other components. Since `JFilechooser` implementation varies based on LookAndFeel, the same had to be taken care for affected LookAndFeel also.
>> Note: `JFrame` being top level container handles frame disable using native method which couldn't be the case for `JFileChooser`. For `showDialog/showOpenDialog/showSaveDialog` the fix could be to set the one the enabled property for created single Dialog. But when an instance of `JFileChooser` is created and added to Frame (Without Dialog been created), disabling the `FileChooser` alone had to be done by handling each sub-components and listeners separately.
>
> Tejesh R has updated the pull request incrementally with one additional commit since the last revision:
>
> Doc update
test/jdk/javax/swing/JFileChooser/FileChooserDisableTest.java line 47:
> 45: * @bug 4365952
> 46: * @key headful
> 47: * @summary Test to check is File chooser can be Disabled
Summary may be changed to "Test to check if JFileChooser can be disabled".
test/jdk/javax/swing/JFileChooser/FileChooserDisableTest.java line 49:
> 47: * @summary Test to check is File chooser can be Disabled
> 48: * @run main FileChooserDisableTest
> 49: */
Please add a blank line after this.
test/jdk/javax/swing/JFileChooser/FileChooserDisableTest.java line 94:
> 92: String currentDirectory = jfc.getCurrentDirectory().toString();
> 93: if (!currentDirectory.equals(defaultDirectory)) {
> 94: throw new RuntimeException("File chooser disable failed");
Better to add the failed LAF name also while throwing exception.
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/16068#discussion_r1366515773
PR Review Comment: https://git.openjdk.org/jdk/pull/16068#discussion_r1366516612
PR Review Comment: https://git.openjdk.org/jdk/pull/16068#discussion_r1366512983
More information about the client-libs-dev
mailing list