Module org.jpo
Package org.jpo.gui

Class DirectoryChooser

All Implemented Interfaces:
ImageObserver, MenuContainer, Serializable, Accessible

public class DirectoryChooser extends JPanel
An object of this class displays a directory field with a dropdown button to select the previously used directories and has a button next to it which allows you to bring up a filechooser. The selected directory is validated whether it exists and is writable. If this is not the case the characters of the textfield are displayed in red.
See Also:
  • Field Details

    • DIR_MUST_BE_WRITABLE

      public static final int DIR_MUST_BE_WRITABLE
      Constant that indicates that the directory must exist and be writable;
      See Also:
  • Constructor Details

    • DirectoryChooser

      public DirectoryChooser(String chooserTitle, int validationType)
      Creates the directory chooser component
      Parameters:
      chooserTitle - The title for a JFileChooser window if the user clicks the button
      validationType - The type of validation that must be performed on the directory. Can either be DIR_MUST_EXIST or DIR_MUST_BE_WRITABLE
  • Method Details

    • setText

      public void setText(String directory)
      Puts the directory into the DirectoryChooserTest
      Parameters:
      directory - The string of the directory to be set in the field
    • setFile

      public void setFile(File directory)
      Set the DirectoryChooserTest to the supplied File
      Parameters:
      directory - The directory to be set in the DirectoryChooserTest
    • addChangeListener

      public void addChangeListener(ChangeListener listener)
      Adds a change listener that will be notified whenever the text in the field changes
      Parameters:
      listener - The listener that should be notified
    • removeChangeListener

      public void removeChangeListener(ChangeListener listener)
      Removes a change listener that no longer wants to know about text changes
      Parameters:
      listener - The listener to remove
    • getDirectory

      public File getDirectory()
      Returns the directory of the chooser as a new File object
      Returns:
      The directory currently selected
    • setEnabled

      public void setEnabled(boolean enabled)
      Sets the DirectoryChooser to enabled or disabled. Delegates this down to the component Swing components.
      Overrides:
      setEnabled in class JComponent
      Parameters:
      enabled - True if enabled, false if not.