Class FileChooserUtils


  • public class FileChooserUtils
    extends java.lang.Object
    Utility class for JFileChooser related functions.
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static void sanitizeCurrentDirectory​(@NotNull javax.swing.JFileChooser fileChooser)
      Makes sure the current directory of a JFileChooser is valid.
      static void setCurrentDirectory​(@NotNull javax.swing.JFileChooser fileChooser, @Nullable java.io.File dir)
      Calls JFileChooser.setCurrentDirectory(File).
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Method Detail

      • setCurrentDirectory

        public static void setCurrentDirectory​(@NotNull
                                               @NotNull javax.swing.JFileChooser fileChooser,
                                               @Nullable
                                               @Nullable java.io.File dir)
        Calls JFileChooser.setCurrentDirectory(File). Makes sure the passed directory exists to minimize the chance for NullPointerExceptions. See Bugreport 4869950.
        Parameters:
        fileChooser - the file chooser to affect
        dir - the directory to set; null=user's home directory
      • sanitizeCurrentDirectory

        public static void sanitizeCurrentDirectory​(@NotNull
                                                    @NotNull javax.swing.JFileChooser fileChooser)
        Makes sure the current directory of a JFileChooser is valid.
        Parameters:
        fileChooser - the file chooser to check