Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8318024

Cannot disable JFileChooser

XMLWordPrintable

    • behavioral
    • low
    • Hide
      There is a small risk that an application has unwittingly called setEnabled(false) on a JFileChooser.
      Whilst that would be an application bug, in such a case the application will not function properly when it begins to be honored.

      Show
      There is a small risk that an application has unwittingly called setEnabled(false) on a JFileChooser. Whilst that would be an application bug, in such a case the application will not function properly when it begins to be honored.
    • Java API
    • SE

      Summary

      The Swing JFileChooser component now honors the enabled property.

      Problem

      Swing provides a method JComponent.setEnabled(boolean) which is supposed to be honored by all sub-classes. The effect of "false" should be that the component does not respond to user input. Directly disabling a JFileChooser like this was not possible as the property was not honored or propagated to its sub-components.

      Solution

      Override the setEnabled(boolean) method from JComponent. This allows it to recursively disable all sub-components and also intercept any action listeners. There is no new javadoc, since the behaviour is now as specified by the superclass.

      Specification

      public class javax.swing.JFileChooser :

      /**
       * {@inheritDoc}
       * @param enabled {@inheritDoc}
       */
      @Override
      public void setEnabled(boolean enabled);

            tr Tejesh R
            skondamasunw Suresh Kondamareddy (Inactive)
            Philip Race
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: