Class FileChooserPanel

All Implemented Interfaces:
ImageObserver, MenuContainer, Serializable, Accessible

public class FileChooserPanel extends AbstractChooserPanel<File>
A panel that contains a text field with the current file/directory and a button for bringing up a BaseFileChooser.
Author:
fracpete (fracpete at waikato dot ac dot nz)
See Also:
  • Field Details

    • m_FileChooser

      protected BaseFileChooser m_FileChooser
      the JFileChooser for selecting a file.
    • m_UseSaveDialog

      protected boolean m_UseSaveDialog
      whether to use the open or save dialog.
  • Constructor Details

    • FileChooserPanel

      public FileChooserPanel()
      Initializes the panel with no file.
    • FileChooserPanel

      public FileChooserPanel(String path)
      Initializes the panel with the given filename/directory.
      Parameters:
      path - the filename/directory to use
    • FileChooserPanel

      public FileChooserPanel(File path)
      Initializes the panel with the given filename/directory.
      Parameters:
      path - the filename/directory to use
  • Method Details

    • initialize

      protected void initialize()
      Initializes the members.
      Overrides:
      initialize in class AbstractChooserPanel<File>
    • doChoose

      protected File doChoose()
      Performs the actual choosing of an object.
      Specified by:
      doChoose in class AbstractChooserPanel<File>
      Returns:
      the chosen object or null if none chosen
    • toString

      protected String toString(File value)
      Converts the value into its string representation.
      Specified by:
      toString in class AbstractChooserPanel<File>
      Parameters:
      value - the value to convert
      Returns:
      the generated string
    • fromString

      protected File fromString(String value)
      Converts the string representation into its object representation.
      Specified by:
      fromString in class AbstractChooserPanel<File>
      Parameters:
      value - the string value to convert
      Returns:
      the generated object
    • setFileSelectionMode

      public void setFileSelectionMode(int value)
      Sets the selection mode, whether only files or directories, or both can be selected. FILES_ONLY is the default.
      Parameters:
      value - the mode
    • getFileSelectionMode

      public int getFileSelectionMode()
      Returns the selection mode, whether only files or directories, or both can be selected. FILES_ONLY is the default.
      Returns:
      the mode
      See Also:
    • addChoosableFileFilter

      public void addChoosableFileFilter(FileFilter value)
      Adds the given file filter to the filechooser.
      Parameters:
      value - the file filter to add
    • removeChoosableFileFilter

      public void removeChoosableFileFilter(FileFilter value)
      Removes the specified file filter from the filechooser.
      Parameters:
      value - the file filter to remove
    • removeChoosableFileFilters

      public void removeChoosableFileFilters()
      Removes all file filters from the filechooser.
    • getChoosableFileFilters

      public FileFilter[] getChoosableFileFilters()
      Returns all choosable file filters.
      Returns:
      the current file filters
    • setAcceptAllFileFilterUsed

      public void setAcceptAllFileFilterUsed(boolean value)
      Sets whether the "accept all files" filter is used.
      Parameters:
      value - if true then the filter will be used
    • isAcceptAllFileFilterUsed

      public boolean isAcceptAllFileFilterUsed()
      Returns whether the "accept all files" filter is used.
      Returns:
      true if the filter is used
    • setFileFilter

      public void setFileFilter(FileFilter value)
      Sets the active file filter.
      Parameters:
      value - the file filter to select
    • getFileFilter

      public FileFilter getFileFilter()
      Returns the active file filter.
      Returns:
      the current file filter
    • setCurrentDirectory

      public void setCurrentDirectory(File value)
      Sets the current directory to use for the file chooser.
      Parameters:
      value - the current directory
    • getCurrentDirectory

      public File getCurrentDirectory()
      Returns the current directory in use by the file chooser.
      Returns:
      the current directory
    • setCurrent

      public boolean setCurrent(File value)
      Sets the current value.
      Overrides:
      setCurrent in class AbstractChooserPanel<File>
      Parameters:
      value - the value to use, can be null
      Returns:
      true if successfully set
    • setUseSaveDialog

      public void setUseSaveDialog(boolean value)
      Sets whether to use the save or open dialog.
      Parameters:
      value - if true the save dialog is used
    • getUseSaveDialog

      public boolean getUseSaveDialog()
      Returns whether the save or open dialog is used.
      Returns:
      true if the save dialog is used