Class FileChooser

All Implemented Interfaces:
ImageObserver, MenuContainer, Serializable, Accessible

public class FileChooser extends JFileChooser
A variant of JFileChooser, with support for file filters based on filename extensions. The chooser also always starts in the user's current directory (instead of home directory).
See Also:
  • Constructor Details

    • FileChooser

      public FileChooser()
      Create a default file chooser.
    • FileChooser

      public FileChooser(boolean showAllFilesFilter)
      Create a file chooser, specifying whether or not it should have a generic file filter for "all files".
      Parameters:
      showAllFilesFilter - true if the "All Files" filter should be available, and false if not.
  • Method Details

    • addChoosableExtension

      public void addChoosableExtension(String extn, String desc)
      Add a choosable file filter based on a filename extension. This filter becomes the default filter.
      Parameters:
      extn - the filename extension used to filter the files to be shown
      desc - the description for files selected by the filter
    • getChosenExtension

      public String getChosenExtension()
      Get a chosen file filter extension.
      Returns:
      an extension or null if not specified
    • enableDirectories

      public void enableDirectories(boolean enableDirs)
      Allows to disable directories browsing
      Parameters:
      enableDirs - true if directories browsing is allowed, false otherwise