Class JFileChooser

All Implemented Interfaces:
ImageObserver, MenuContainer, Serializable, Accessible

public class JFileChooser extends JFileChooser
JFileChooser.java

JFileChooser that tracks the last visited directory for a given ID. It allows you to open the JFileChooser in the same directory where you were the last time you open a file in the file system.

It needs to specify a string defining the JFileChooser ID in order to know what kind of files you are going to open. For example after creating a JFileChooser by doing this:
new JFileChooser("TEMPLATES_FILECHOOSER", defaultDirectory);
each time you create another JFileChooser anywhere giving the same ID, it will point directly to the last directory where you opened a file using this JFileChooser with an equal ID.

Author:
jaume dominguez faus - jaume.dominguez@iver.es Dec 5, 2007
See Also:
  • Constructor Details

    • JFileChooser

      public JFileChooser(String fileChooserID, File defaultDirectory)
      Creates a new JFileChooser with the remind last path feature.
      Parameters:
      fileChooserID - , the id that distinguishes the wanted files (i.e. "TEMPLATES_FILECHOOSER")
      defaultDirectory - , the default directory to go for the first time. It allows null, which means the user's home directory.
    • JFileChooser

      public JFileChooser(String fileChooserID, String defaultDirectory)
      Creates a new JFileChooser with the remind last path feature.
      Parameters:
      fileChooserID - , the id that distinguishes the wanted files (i.e. "TEMPLATES_FILECHOOSER")
      defaultDirectory - , the default directory to go for the first time. It allows null, which means the user's home directory.
    • JFileChooser

      public JFileChooser(String fileChooserID, FileSystemView fsv)
      Constructs a JFileChooser using the given FileSystemView.
    • JFileChooser

      public JFileChooser(String fileChooserID, File defaultDirectory, FileSystemView fsv)
      Constructs a JFileChooser using the given current directory and FileSystemView.
    • JFileChooser

      public JFileChooser(String fileChooserID, String defaultDirectoryPath, FileSystemView fsv)
      Constructs a JFileChooser using the given current directory path and FileSystemView.
  • Method Details

    • getLastPath

      public static File getLastPath(String fileChooserID, File defaultDirectory)
      Returns the Last Path for this fileChooserID
      Parameters:
      fileChooserID - , the id that distinguishes the wanted files (i.e. "TEMPLATES_FILECHOOSER")
      defaultDirectory - , the default directory to go for the first time. It allows null, which means the user's home directory.
      Returns:
    • getLastPath

      public File getLastPath(File defaultDirectory)
      Returns the Last Path for this JFileChooser
      Parameters:
      defaultDirectory - , the default directory to go for the first time. It allows null, which means the user's home directory.
      Returns:
    • getLastPath

      public File getLastPath()
      Returns the Last Path for this JFileChooser
      Returns:
    • setLastPath

      public static void setLastPath(String fileChooserID, File path)
      Save the Last Path for this fileChooserID
      Parameters:
      fileChooserID -
      path -
    • setLastPath

      public void setLastPath(File path)
      Save the Last Path for this JFileChooser
      Parameters:
      path -
    • showDialog

      public int showDialog(Component parent, String approveButtonText) throws HeadlessException
      Overrides:
      showDialog in class JFileChooser
      Throws:
      HeadlessException