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

RFE: JFileChooser needs DefaultFileFilter class

XMLWordPrintable

    • b72
    • generic, x86, sparc
    • generic, linux, solaris_8

      In JFileChooser you can selectively show the exact files you want the
      user to deal with by providing a FileFilter. The FileFilter class is
      abstract, and no default implementation is provided.

      While it's relatively easy to implement a FileFilter class, this is a
      conceptual hurdle - ya'mean'I'gotta'write'some'extra'code whining, in other
      words. This is yet another example of atoms, where a couple simple-to-use
      molecules would be useful in addition. For example many of the other
      complex components provide DefaultXXXModel objects that tend to make it
      easier to use the component, so why not FileFilter.

      This is doubly true given the example in the javadoc, where you suggest the
      programmer use "ExampleFileFilter" and say

         filter.addExtension("gif");
         filter.addExtension("jpg");

      No doubt legions of programmers have read that suggestion, looked around in
      desparation for the ExampleFileFilter class, and whined about having to
      write it themselves.

      So here's the proposal; provide DefaultFileFilter as an implementation of
      the FileFilter abstract class. The API would be as suggested by the
      JFileFilter javadoc:

        addExtension(String) - Add's an extension to be considered.
        removeExtension(String) - Removes an extension from consideration
        setDescription(String) - Set the description

            svioletsunw Scott Violet (Inactive)
            dherronsunw David Herron (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: