Class UniversalFileFilter


  • public class UniversalFileFilter
    extends FileFilter
    A convenience implementation of FileFilter that filters out all files except for those type extensions that it knows about. Extensions are of the type ".foo", which is typically found on Windows and Unix boxes, but not on Macinthosh. Case is ignored. Example - create a new filter that filerts out all files but gif and jpg image files:
     
         JFileChooser chooser = new JFileChooser();
         UniversalFileFilter filter = new UniversalFileFilter(
                       new String{"gif", "jpg"}, "JPEG & GIF Images")
         chooser.addChoosableFileFilter(filter);
         chooser.showOpenDialog(this);
     
     
    • Constructor Detail

      • UniversalFileFilter

        public UniversalFileFilter()
        Creates a file filter. If no filters are added, then all files are accepted.
        See Also:
        addExtension(java.lang.String)
      • UniversalFileFilter

        public UniversalFileFilter​(String[] filters)
        Creates a file filter from the given string array. Example: new ExampleFileFilter(String {"gif", "jpg"}); Note that the "." before the extension is not needed adn will be ignored.
        Parameters:
        filters - filters
        See Also:
        addExtension(java.lang.String)
      • UniversalFileFilter

        public UniversalFileFilter​(String[] filters,
                                   String description)
        Creates a file filter from the given string array and description. Example: new ExampleFileFilter(String {"gif", "jpg"}, "Gif and JPG Images"); Note that the "." before the extension is not needed and will be ignored.
        Parameters:
        filters - filters
        description - description
        See Also:
        addExtension(java.lang.String)
      • UniversalFileFilter

        public UniversalFileFilter​(String extension)
        Creates a file filter that accepts files with the given extension. Example: new ExampleFileFilter("jpg");
        Parameters:
        extension - extension
        See Also:
        addExtension(java.lang.String)
      • UniversalFileFilter

        public UniversalFileFilter​(String extension,
                                   String description)
        Creates a file filter that accepts the given file type. Example: new ExampleFileFilter("jpg", "JPEG Image Images"); Note that the "." before the extension is not needed. If provided, it will be ignored.
        Parameters:
        extension - extension
        description - description
        See Also:
        addExtension(java.lang.String)