Class FileSelector

All Implemented Interfaces:
FocusListener, ImageObserver, MenuContainer, Serializable, EventListener, Accessible

public class FileSelector extends JPanel implements FocusListener
Composite component to allow file or directory input or selection. Comprises a JTextField, and a browse button associated with a JFileChooser.
See Also:
  • Constructor Details

    • FileSelector

      public FileSelector(String initialValue, String fileChooserTitle, int selectionMode)
      Creates a new FileSelector.
      Parameters:
      initialValue - filename initially displayed in the text field
      fileChooserTitle - title of the JFileChooser launched when the user clicks Browse
      selectionMode - Can be either JFileChooser.FILES_ONLY, JFileChooser.DIRECTORIES_ONLY or JFileChooser.FILES_AND_DIRECTORIES
    • FileSelector

      public FileSelector(String initialValue, String fileChooserTitle, int selectionMode, File currentDir)
      Creates a new FileSelector.
      Parameters:
      initialValue - filename initially displayed in the text field
      fileChooserTitle - title of the JFileChooser launched when the user clicks Browse
      selectionMode - Can be either JFileChooser.FILES_ONLY, JFileChooser.DIRECTORIES_ONLY or JFileChooser.FILES_AND_DIRECTORIES
      currentDir - default directory for the file chooser
    • FileSelector

      public FileSelector(String initialValue, String fileChooserTitle, int selectionMode, File currentDir, FileFilter filter)
      Creates a new FileSelector.
      Parameters:
      initialValue - filename initially displayed in the text field
      fileChooserTitle - title of the JFileChooser launched when the user clicks Browse
      selectionMode - Can be either JFileChooser.FILES_ONLY, JFileChooser.DIRECTORIES_ONLY or JFileChooser.FILES_AND_DIRECTORIES
      currentDir - default directory for the file chooser
      filter - file filter used by the file chooser
  • Method Details

    • addFileSelectorListener

      public void addFileSelectorListener(FileSelectorListener fileSelectorListener, JComponent source)
      Adds the file selector listener.
      Parameters:
      fileSelectorListener - the file selector listener
      source - the source
    • getSelected

      public String getSelected()
      Gets the selected.
      Returns:
      the selected
    • setSelected

      public void setSelected(String s)
      Sets the selected.
      Parameters:
      s - the new selected
    • setEnabled

      public void setEnabled(boolean onOff)
      Overrides:
      setEnabled in class JComponent
    • clear

      public void clear()
      Clear.
    • focusGained

      public void focusGained(FocusEvent aEvent)
      Specified by:
      focusGained in interface FocusListener
    • focusLost

      public void focusLost(FocusEvent aEvent)
      Specified by:
      focusLost in interface FocusListener
    • getFileChooser

      protected JFileChooser getFileChooser()
      Get the File Chooser user when the Browse button is clicked. This is lazily created when needed, because of issue UIMA-231.
      Returns:
      the file chooser