# Class BasicFileChooserUI

java.lang.Object
javax.swing.plaf.ComponentUI
javax.swing.plaf.FileChooserUI
javax.swing.plaf.basic.BasicFileChooserUI

Direct Known Subclasses:
  `MetalFileChooserUI`

public class BasicFileChooserUI extends FileChooserUI
Basic L&F implementation of a FileChooser.

- ## Nested Class Summary

  Nested Classes
  Modifier and Type
  Class
  Description
  `protected class`
  `BasicFileChooserUI.AcceptAllFileFilter`
  Accept all file filter.
  `protected class`
  `BasicFileChooserUI.ApproveSelectionAction`
  Responds to an Open or Save request
  `protected class`
  `BasicFileChooserUI.BasicFileView`
  A basic file view.
  `protected class`
  `BasicFileChooserUI.CancelSelectionAction`
  Responds to a cancel request.
  `protected class`
  `BasicFileChooserUI.ChangeToParentDirectoryAction`
  Change to parent directory action.
  `protected class`
  `BasicFileChooserUI.DoubleClickListener`
  A double click listener.
  `protected class`
  `BasicFileChooserUI.GoHomeAction`
  Acts on the "home" key event or equivalent event.
  `protected class`
  `BasicFileChooserUI.NewFolderAction`
  Creates a new folder.
  `protected class`
  `BasicFileChooserUI.SelectionListener`
  A selection listener.
  `protected class`
  `BasicFileChooserUI.UpdateAction`
  Rescans the files in the current directory

- ## Field Summary

  Fields
  Modifier and Type
  Field
  Description
  `protected int`
  `cancelButtonMnemonic`
  Cancel button mnemonic
  `protected String`
  `cancelButtonText`
  Cancel button text
  `protected String`
  `cancelButtonToolTipText`
  Cancel button tool tip text
  `protected Icon`
  `computerIcon`
  Computer icon
  `protected Icon`
  `detailsViewIcon`
  Details view icon
  `protected Icon`
  `directoryIcon`
  Directory icon
  `protected int`
  `directoryOpenButtonMnemonic`
  The mnemonic keycode used for the approve button when a directory is selected and the current selection mode is FILES_ONLY.
  `protected String`
  `directoryOpenButtonText`
  The label text displayed on the approve button when a directory is selected and the current selection mode is FILES_ONLY.
  `protected String`
  `directoryOpenButtonToolTipText`
  The tooltip text displayed on the approve button when a directory is selected and the current selection mode is FILES_ONLY.
  `protected Icon`
  `fileIcon`
  File icon
  `protected Icon`
  `floppyDriveIcon`
  Floppy drive icon
  `protected Icon`
  `hardDriveIcon`
  Hard drive icon
  `protected int`
  `helpButtonMnemonic`
  Help button mnemonic
  `protected String`
  `helpButtonText`
  Help button text
  `protected String`
  `helpButtonToolTipText`
  Help button tool tip text
  `protected Icon`
  `homeFolderIcon`
  Home folder icon
  `protected Icon`
  `listViewIcon`
  List view icon
  `protected Icon`
  `newFolderIcon`
  New folder icon
  `protected int`
  `openButtonMnemonic`
  Open button mnemonic
  `protected String`
  `openButtonText`
  Open button text
  `protected String`
  `openButtonToolTipText`
  Open button tool tip text
  `protected int`
  `saveButtonMnemonic`
  Save button mnemonic
  `protected String`
  `saveButtonText`
  Save button text
  `protected String`
  `saveButtonToolTipText`
  Save button tool tip text
  `protected int`
  `updateButtonMnemonic`
  Update button mnemonic
  `protected String`
  `updateButtonText`
  Update button text
  `protected String`
  `updateButtonToolTipText`
  Update button tool tip text
  `protected Icon`
  `upFolderIcon`
  Up folder icon
  `protected Icon`
  `viewMenuIcon`
  View menu icon

- ## Constructor Summary

  Constructors
  Constructor
  Description
  `BasicFileChooserUI(JFileChooser b)`
  Constructs a `BasicFileChooserUI`.

- ## Method Summary

  Modifier and Type
  Method
  Description
  `void`
  `clearIconCache()`
  Clears the icon cache.
  `protected MouseListener`
  `createDoubleClickListener(JFileChooser fc, JList<?> list)`
  Creates a double click listener.
  `ListSelectionListener`
  `createListSelectionListener(JFileChooser fc)`
  Creates a list selection listener.
  `protected void`
  `createModel()`
  Creates the model.
  `PropertyChangeListener`
  `createPropertyChangeListener(JFileChooser fc)`
  Creates the property change listener.
  `static ComponentUI`
  `createUI(JComponent c)`
  Creates a `BasicFileChooserUI` implementation for the specified component.
  `void`
  `ensureFileIsVisible(JFileChooser fc, File f)`
  Ensure the file in question is visible.
  `FileFilter`
  `getAcceptAllFileFilter(JFileChooser fc)`
  Returns the default accept all file filter
  `JPanel`
  `getAccessoryPanel()`
  Returns the accessory panel.
  `protected JButton`
  `getApproveButton(JFileChooser fc)`
  Returns the approve button.
  `int`
  `getApproveButtonMnemonic(JFileChooser fc)`
  Returns the approve button mnemonic.
  `String`
  `getApproveButtonText(JFileChooser fc)`
  Returns approve button text.
  `String`
  `getApproveButtonToolTipText(JFileChooser fc)`
  Returns the approve button tool tip.
  `Action`
  `getApproveSelectionAction()`
  Returns an approve selection action.
  `Action`
  `getCancelSelectionAction()`
  Returns a cancel selection action.
  `Action`
  `getChangeToParentDirectoryAction()`
  Returns a change to parent directory action.
  `String`
  `getDialogTitle(JFileChooser fc)`
  Returns the title of this dialog
  `protected File`
  `getDirectory()`
  Property to remember the directory that is currently selected in the UI.
  `String`
  `getDirectoryName()`
  Returns the directory name.
  `JFileChooser`
  `getFileChooser()`
  Returns the file chooser.
  `String`
  `getFileName()`
  Returns the file name.
  `FileView`
  `getFileView(JFileChooser fc)`
  Returns a file view.
  `Action`
  `getGoHomeAction()`
  Returns a go home action.
  `BasicDirectoryModel`
  `getModel()`
  Returns the model.
  `Action`
  `getNewFolderAction()`
  Returns a new folder action.
  `Action`
  `getUpdateAction()`
  Returns an update action.
  `void`
  `installComponents(JFileChooser fc)`
  Installs the components.
  `protected void`
  `installDefaults(JFileChooser fc)`
  Installs the defaults.
  `protected void`
  `installIcons(JFileChooser fc)`
  Installs the icons.
  `protected void`
  `installListeners(JFileChooser fc)`
  Installs the listeners.
  `protected void`
  `installStrings(JFileChooser fc)`
  Installs the strings.
  `void`
  `installUI(JComponent c)`
  Installs the UI.
  `protected boolean`
  `isDirectorySelected()`
  Property to remember whether a directory is currently selected in the UI.
  `void`
  `rescanCurrentDirectory(JFileChooser fc)`
  Rescan the current directory.
  `protected void`
  `setDirectory(File f)`
  Property to remember the directory that is currently selected in the UI.
  `void`
  `setDirectoryName(String dirname)`
  Sets the directory name.
  `protected void`
  `setDirectorySelected(boolean b)`
  Property to remember whether a directory is currently selected in the UI.
  `void`
  `setFileName(String filename)`
  Sets the file name.
  `void`
  `uninstallComponents(JFileChooser fc)`
  Uninstalls the components.
  `protected void`
  `uninstallDefaults(JFileChooser fc)`
  Uninstalls the defaults.
  `protected void`
  `uninstallIcons(JFileChooser fc)`
  Uninstalls the icons.
  `protected void`
  `uninstallListeners(JFileChooser fc)`
  Uninstalls the listeners.
  `protected void`
  `uninstallStrings(JFileChooser fc)`
  Uninstalls the strings.
  `void`
  `uninstallUI(JComponent c)`
  Uninstalls the UI.

  ### Methods declared in class FileChooserUI

  `getDefaultButton`
  Modifier and Type
  Method
  Description
  `JButton`
  `getDefaultButton(JFileChooser fc)`
  Returns default button for current `LookAndFeel`.

  ### Methods declared in class ComponentUI

  `contains, getAccessibleChild, getAccessibleChildrenCount, getBaseline, getBaselineResizeBehavior, getMaximumSize, getMinimumSize, getPreferredSize, paint, update`
  Modifier and Type
  Method
  Description
  `boolean`
  `contains(JComponent c, int x, int y)`
  Returns `true` if the specified x,y location is contained within the look and feel's defined shape of the specified component.
  `Accessible`
  `getAccessibleChild(JComponent c, int i)`
  Returns the `i`th `Accessible` child of the object.
  `int`
  `getAccessibleChildrenCount(JComponent c)`
  Returns the number of accessible children in the object.
  `int`
  `getBaseline(JComponent c, int width, int height)`
  Returns the baseline.
  `Component.BaselineResizeBehavior`
  `getBaselineResizeBehavior(JComponent c)`
  Returns an enum indicating how the baseline of the component changes as the size changes.
  `Dimension`
  `getMaximumSize(JComponent c)`
  Returns the specified component's maximum size appropriate for the look and feel.
  `Dimension`
  `getMinimumSize(JComponent c)`
  Returns the specified component's minimum size appropriate for the look and feel.
  `Dimension`
  `getPreferredSize(JComponent c)`
  Returns the specified component's preferred size appropriate for the look and feel.
  `void`
  `paint(Graphics g, JComponent c)`
  Paints the specified component appropriately for the look and feel.
  `void`
  `update(Graphics g, JComponent c)`
  Notifies this UI delegate that it is time to paint the specified component.

  ### Methods declared in class Object

  `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`
  Modifier and Type
  Method
  Description
  `protected Object`
  `clone()`
  Creates and returns a copy of this object.
  `boolean`
  `equals(Object obj)`
  Indicates whether some other object is "equal to" this one.
  `protected void`
  `finalize()`
  Deprecated, for removal: This API element is subject to removal in a future version.
  Finalization is deprecated and subject to removal in a future release.
  `final Class<?>`
  `getClass()`
  Returns the runtime class of this `Object`.
  `int`
  `hashCode()`
  Returns a hash code value for this object.
  `final void`
  `notify()`
  Wakes up a single thread that is waiting on this object's monitor.
  `final void`
  `notifyAll()`
  Wakes up all threads that are waiting on this object's monitor.
  `String`
  `toString()`
  Returns a string representation of the object.
  `final void`
  `wait()`
  Causes the current thread to wait until it is awakened, typically by being notified or interrupted.
  `final void`
  `wait(long timeoutMillis)`
  Causes the current thread to wait until it is awakened, typically by being notified or interrupted, or until a certain amount of real time has elapsed.
  `final void`
  `wait(long timeoutMillis, int nanos)`
  Causes the current thread to wait until it is awakened, typically by being notified or interrupted, or until a certain amount of real time has elapsed.

- ## Field Details

  - ### directoryIcon

    protected Icon directoryIcon
    Directory icon

  - ### fileIcon

    protected Icon fileIcon
    File icon

  - ### computerIcon

    protected Icon computerIcon
    Computer icon

  - ### hardDriveIcon

    protected Icon hardDriveIcon
    Hard drive icon

  - ### floppyDriveIcon

    protected Icon floppyDriveIcon
    Floppy drive icon

  - ### newFolderIcon

    protected Icon newFolderIcon
    New folder icon

  - ### upFolderIcon

    protected Icon upFolderIcon
    Up folder icon

  - ### homeFolderIcon

    protected Icon homeFolderIcon
    Home folder icon

  - ### listViewIcon

    protected Icon listViewIcon
    List view icon

  - ### detailsViewIcon

    protected Icon detailsViewIcon
    Details view icon

  - ### viewMenuIcon

    protected Icon viewMenuIcon
    View menu icon

  - ### saveButtonMnemonic

    protected int saveButtonMnemonic
    Save button mnemonic

  - ### openButtonMnemonic

    protected int openButtonMnemonic
    Open button mnemonic

  - ### cancelButtonMnemonic

    protected int cancelButtonMnemonic
    Cancel button mnemonic

  - ### updateButtonMnemonic

    protected int updateButtonMnemonic
    Update button mnemonic

  - ### helpButtonMnemonic

    protected int helpButtonMnemonic
    Help button mnemonic

  - ### directoryOpenButtonMnemonic

    protected int directoryOpenButtonMnemonic
    The mnemonic keycode used for the approve button when a directory is selected and the current selection mode is FILES_ONLY.
    Since:
      1.4

  - ### saveButtonText

    protected String saveButtonText
    Save button text

  - ### openButtonText

    protected String openButtonText
    Open button text

  - ### cancelButtonText

    protected String cancelButtonText
    Cancel button text

  - ### updateButtonText

    protected String updateButtonText
    Update button text

  - ### helpButtonText

    protected String helpButtonText
    Help button text

  - ### directoryOpenButtonText

    protected String directoryOpenButtonText
    The label text displayed on the approve button when a directory is selected and the current selection mode is FILES_ONLY.
    Since:
      1.4

  - ### saveButtonToolTipText

    protected String saveButtonToolTipText
    Save button tool tip text

  - ### openButtonToolTipText

    protected String openButtonToolTipText
    Open button tool tip text

  - ### cancelButtonToolTipText

    protected String cancelButtonToolTipText
    Cancel button tool tip text

  - ### updateButtonToolTipText

    protected String updateButtonToolTipText
    Update button tool tip text

  - ### helpButtonToolTipText

    protected String helpButtonToolTipText
    Help button tool tip text

  - ### directoryOpenButtonToolTipText

    protected String directoryOpenButtonToolTipText
    The tooltip text displayed on the approve button when a directory is selected and the current selection mode is FILES_ONLY.
    Since:
      1.4

- ## Constructor Details

  - ### BasicFileChooserUI

    public BasicFileChooserUI(JFileChooser b)
    Constructs a `BasicFileChooserUI`.
    Parameters:
      `b` - file chooser

- ## Method Details

  - ### createUI

    public static ComponentUI createUI(JComponent c)
    Creates a `BasicFileChooserUI` implementation for the specified component. By default the `BasicLookAndFeel` class uses `createUI` methods of all basic UIs classes to instantiate UIs.
    Parameters:
      `c` - the `JFileChooser` which needs a UI
    Returns:
      the `BasicFileChooserUI` object
    Since:
      1.7
    See Also:
      - `UIDefaults.getUI(JComponent)`

  - ### installUI

    public void installUI(JComponent c)
    Installs the UI.
    Overrides:
      `installUI` in class `ComponentUI`
    Parameters:
      `c` - the component
    See Also:
      - `ComponentUI.uninstallUI(JComponent)`
      - `JComponent.setUI(ComponentUI)`
      - `JComponent.updateUI()`

  - ### uninstallUI

    public void uninstallUI(JComponent c)
    Uninstalls the UI.
    Overrides:
      `uninstallUI` in class `ComponentUI`
    Parameters:
      `c` - the component
    See Also:
      - `ComponentUI.installUI(JComponent)`
      - `JComponent.updateUI()`

  - ### installComponents

    public void installComponents(JFileChooser fc)
    Installs the components.
    Parameters:
      `fc` - the file chooser

  - ### uninstallComponents

    public void uninstallComponents(JFileChooser fc)
    Uninstalls the components.
    Parameters:
      `fc` - the file chooser

  - ### installListeners

    protected void installListeners(JFileChooser fc)
    Installs the listeners.
    Parameters:
      `fc` - the file chooser

  - ### uninstallListeners

    protected void uninstallListeners(JFileChooser fc)
    Uninstalls the listeners.
    Parameters:
      `fc` - the file chooser

  - ### installDefaults

    protected void installDefaults(JFileChooser fc)
    Installs the defaults.
    Parameters:
      `fc` - the file chooser

  - ### installIcons

    protected void installIcons(JFileChooser fc)
    Installs the icons.
    Parameters:
      `fc` - the file chooser

  - ### installStrings

    protected void installStrings(JFileChooser fc)
    Installs the strings.
    Parameters:
      `fc` - the file chooser

  - ### uninstallDefaults

    protected void uninstallDefaults(JFileChooser fc)
    Uninstalls the defaults.
    Parameters:
      `fc` - the file chooser

  - ### uninstallIcons

    protected void uninstallIcons(JFileChooser fc)
    Uninstalls the icons.
    Parameters:
      `fc` - the file chooser

  - ### uninstallStrings

    protected void uninstallStrings(JFileChooser fc)
    Uninstalls the strings.
    Parameters:
      `fc` - the file chooser

  - ### createModel

    protected void createModel()
    Creates the model.

  - ### getModel

    public BasicDirectoryModel getModel()
    Returns the model.
    Returns:
      the model

  - ### createPropertyChangeListener

    public PropertyChangeListener createPropertyChangeListener(JFileChooser fc)
    Creates the property change listener.
    Parameters:
      `fc` - the file chooser
    Returns:
      the property change listener

  - ### getFileName

    public String getFileName()
    Returns the file name.
    Returns:
      the file name

  - ### getDirectoryName

    public String getDirectoryName()
    Returns the directory name.
    Returns:
      the directory name

  - ### setFileName

    public void setFileName(String filename)
    Sets the file name.
    Parameters:
      `filename` - the file name

  - ### setDirectoryName

    public void setDirectoryName(String dirname)
    Sets the directory name.
    Parameters:
      `dirname` - the file name

  - ### rescanCurrentDirectory

    public void rescanCurrentDirectory(JFileChooser fc)
    Rescan the current directory.
    Specified by:
      `rescanCurrentDirectory` in class `FileChooserUI`
    Parameters:
      `fc` - the file chooser

  - ### ensureFileIsVisible

    public void ensureFileIsVisible(JFileChooser fc, File f)
    Ensure the file in question is visible.
    Specified by:
      `ensureFileIsVisible` in class `FileChooserUI`
    Parameters:
      `fc` - the file chooser
      `f` - the file

  - ### getFileChooser

    public JFileChooser getFileChooser()
    Returns the file chooser.
    Returns:
      the file chooser

  - ### getAccessoryPanel

    public JPanel getAccessoryPanel()
    Returns the accessory panel.
    Returns:
      the accessory panel

  - ### getApproveButton

    protected JButton getApproveButton(JFileChooser fc)
    Returns the approve button.
    Parameters:
      `fc` - the file chooser
    Returns:
      the approve button

  - ### getApproveButtonToolTipText

    public String getApproveButtonToolTipText(JFileChooser fc)
    Returns the approve button tool tip.
    Parameters:
      `fc` - the file chooser
    Returns:
      the approve button tool tip

  - ### clearIconCache

    public void clearIconCache()
    Clears the icon cache.

  - ### createDoubleClickListener

    protected MouseListener createDoubleClickListener(JFileChooser fc, JList<?> list)
    Creates a double click listener.
    Parameters:
      `fc` - the file chooser
      `list` - the list
    Returns:
      a double click listener

  - ### createListSelectionListener

    public ListSelectionListener createListSelectionListener(JFileChooser fc)
    Creates a list selection listener.
    Parameters:
      `fc` - the file chooser
    Returns:
      a list selection listener

  - ### isDirectorySelected

    protected boolean isDirectorySelected()
    Property to remember whether a directory is currently selected in the UI.
    Returns:
      `true` iff a directory is currently selected.
    Since:
      1.4

  - ### setDirectorySelected

    protected void setDirectorySelected(boolean b)
    Property to remember whether a directory is currently selected in the UI. This is normally called by the UI on a selection event.
    Parameters:
      `b` - iff a directory is currently selected.
    Since:
      1.4

  - ### getDirectory

    protected File getDirectory()
    Property to remember the directory that is currently selected in the UI.
    Returns:
      the value of the `directory` property
    Since:
      1.4
    See Also:
      - `setDirectory(File)`

  - ### setDirectory

    protected void setDirectory(File f)
    Property to remember the directory that is currently selected in the UI. This is normally called by the UI on a selection event.
    Parameters:
      `f` - the `File` object representing the directory that is currently selected
    Since:
      1.4

  - ### getAcceptAllFileFilter

    public FileFilter getAcceptAllFileFilter(JFileChooser fc)
    Returns the default accept all file filter
    Specified by:
      `getAcceptAllFileFilter` in class `FileChooserUI`
    Parameters:
      `fc` - the file chooser
    Returns:
      an accept-all file filter

  - ### getFileView

    public FileView getFileView(JFileChooser fc)
    Description copied from class: `FileChooserUI`
    Returns a file view.
    Specified by:
      `getFileView` in class `FileChooserUI`
    Parameters:
      `fc` - the file chooser
    Returns:
      a file view

  - ### getDialogTitle

    public String getDialogTitle(JFileChooser fc)
    Returns the title of this dialog
    Specified by:
      `getDialogTitle` in class `FileChooserUI`
    Parameters:
      `fc` - the file chooser
    Returns:
      the title of this dialog

  - ### getApproveButtonMnemonic

    public int getApproveButtonMnemonic(JFileChooser fc)
    Returns the approve button mnemonic.
    Parameters:
      `fc` - the file chooser
    Returns:
      the approve button mnemonic

  - ### getApproveButtonText

    public String getApproveButtonText(JFileChooser fc)
    Returns approve button text.
    Specified by:
      `getApproveButtonText` in class `FileChooserUI`
    Parameters:
      `fc` - the file chooser
    Returns:
      approve button text.

  - ### getNewFolderAction

    public Action getNewFolderAction()
    Returns a new folder action.
    Returns:
      a new folder action

  - ### getGoHomeAction

    public Action getGoHomeAction()
    Returns a go home action.
    Returns:
      a go home action

  - ### getChangeToParentDirectoryAction

    public Action getChangeToParentDirectoryAction()
    Returns a change to parent directory action.
    Returns:
      a change to parent directory action

  - ### getApproveSelectionAction

    public Action getApproveSelectionAction()
    Returns an approve selection action.
    Returns:
      an approve selection action

  - ### getCancelSelectionAction

    public Action getCancelSelectionAction()
    Returns a cancel selection action.
    Returns:
      a cancel selection action

  - ### getUpdateAction

    public Action getUpdateAction()
    Returns an update action.
    Returns:
      an update action