On Wed, 7 Dec 2022 10:27:49 GMT, Sergey Bylokhov <s...@openjdk.org> wrote:

>> Disable functionality not working for JFileChooser. `public void 
>> setEnabled(boolean enabled)` functionality is overridden in JFileChooser 
>> class which enable/disable each sub-component of FileChooser. 
>> The added functionality is tested in mach5 and no regression found. The fix 
>> includes automated test which clicks _home_ directory and then compares 
>> which default selectedDirectory to check if JFileChooser is disabled. This 
>> is tested in mach5 for all platforms with multiple test runs.
>
> src/java.desktop/share/classes/javax/swing/JFileChooser.java line 420:
> 
>> 418: 
>> 419:     @Override
>> 420:     public void setEnabled(boolean enabled) {
> 
> Can you please check why a similar example using JFrame and button works 
> fine, but the JFileChooser does not work?
> 
>         JFrame frame = new JFrame();
>         JButton button = new JButton("1234567890");
>         frame.add(button);
>         frame.setVisible(true);
>         frame.setEnabled(false);
>         boolean enabled = button.isEnabled();
>         System.out.println("enabled = " + enabled);

JFileChooser added to a JFrame similar to the example also works, I guess it's 
because frame is made inaccessible. But when we try to disable JFileChooser 
alone, it's not working because we need to disable each sub-component in which 
JFileChooser is made up of. As per debugging I found out that peer component is 
showing null for JFileChooser.disable whereas for JFrame the disabling is taken 
care by peer component in Component class.

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

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

Reply via email to