# Class MetalFileChooserUI

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

public class MetalFileChooserUI extends BasicFileChooserUI
Metal L&F implementation of a FileChooser.

## Nested Class Summary

Nested Classes
Modifier and Type
Class
Description
`protected class`
`MetalFileChooserUI.DirectoryComboBoxAction`
Acts when DirectoryComboBox has changed the selected item.
`protected class`
`MetalFileChooserUI.DirectoryComboBoxModel`
Data model for a type-face selection combo-box.
`protected class`
`MetalFileChooserUI.FileRenderer`
Deprecated.
As of JDK version 9.
`protected class`
`MetalFileChooserUI.FilterComboBoxModel`
Data model for a type-face selection combo-box.
`class`
`MetalFileChooserUI.FilterComboBoxRenderer`
Render different type sizes and styles.
`protected class`
`MetalFileChooserUI.SingleClickListener`
Deprecated.
As of JDK version 9.

### Nested classes/interfaces declared in class BasicFileChooserUI

`BasicFileChooserUI.AcceptAllFileFilter, BasicFileChooserUI.ApproveSelectionAction, BasicFileChooserUI.BasicFileView, BasicFileChooserUI.CancelSelectionAction, BasicFileChooserUI.ChangeToParentDirectoryAction, BasicFileChooserUI.DoubleClickListener, BasicFileChooserUI.GoHomeAction, BasicFileChooserUI.NewFolderAction, BasicFileChooserUI.SelectionListener, BasicFileChooserUI.UpdateAction`
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 declared in class BasicFileChooserUI

`cancelButtonMnemonic, cancelButtonText, cancelButtonToolTipText, computerIcon, detailsViewIcon, directoryIcon, directoryOpenButtonMnemonic, directoryOpenButtonText, directoryOpenButtonToolTipText, fileIcon, floppyDriveIcon, hardDriveIcon, helpButtonMnemonic, helpButtonText, helpButtonToolTipText, homeFolderIcon, listViewIcon, newFolderIcon, openButtonMnemonic, openButtonText, openButtonToolTipText, saveButtonMnemonic, saveButtonText, saveButtonToolTipText, updateButtonMnemonic, updateButtonText, updateButtonToolTipText, upFolderIcon, viewMenuIcon`
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
`MetalFileChooserUI(JFileChooser filechooser)`
Constructs a new instance of `MetalFileChooserUI`.

## Method Summary

Modifier and Type
Method
Description
`protected void`
`addControlButtons()`
Adds control buttons to bottom panel.
`protected ActionMap`
`createActionMap()`
Constructs an instance of `ActionMap`.
`protected JPanel`
`createDetailsView(JFileChooser fc)`
Constructs a details view.
`protected MetalFileChooserUI.DirectoryComboBoxModel`
`createDirectoryComboBoxModel(JFileChooser fc)`
Constructs a new instance of `DataModel` for `DirectoryComboBox`.
`protected MetalFileChooserUI.FilterComboBoxModel`
`createFilterComboBoxModel()`
Constructs a `DataModel` for types `ComboBox`.
`protected MetalFileChooserUI.FilterComboBoxRenderer`
`createFilterComboBoxRenderer()`
Constructs a `Renderer` for types `ComboBox`.
`protected JPanel`
`createList(JFileChooser fc)`
Constructs a details view.
`ListSelectionListener`
`createListSelectionListener(JFileChooser fc)`
Creates a selection listener for the list of files and directories.
`static ComponentUI`
`createUI(JComponent c)`
Constructs a new instance of `MetalFileChooserUI`.
`protected ActionMap`
`getActionMap()`
Returns an instance of `ActionMap`.
`protected JPanel`
`getBottomPanel()`
Returns the bottom panel.
`protected JPanel`
`getButtonPanel()`
Returns the button panel.
`String`
`getDirectoryName()`
Returns the directory name.
`Dimension`
`getMaximumSize(JComponent c)`
Returns the maximum size of the `JFileChooser`.
`Dimension`
`getMinimumSize(JComponent c)`
Returns the minimum size of the `JFileChooser`.
`Dimension`
`getPreferredSize(JComponent c)`
Returns the preferred size of the specified `JFileChooser`.
`protected void`
`removeControlButtons()`
Removes control buttons from bottom panel.
`void`
`setDirectoryName(String dirname)`
Sets the directory name.
`protected void`
`setDirectorySelected(boolean directorySelected)`
Property to remember whether a directory is currently selected in the UI.
`void`
`valueChanged(ListSelectionEvent e)`
Invokes when `ListSelectionEvent` occurs.

### Methods declared in class BasicFileChooserUI

`clearIconCache, createDoubleClickListener, createModel, createPropertyChangeListener, ensureFileIsVisible, getAcceptAllFileFilter, getAccessoryPanel, getApproveButton, getApproveButtonMnemonic, getApproveButtonText, getApproveButtonToolTipText, getApproveSelectionAction, getCancelSelectionAction, getChangeToParentDirectoryAction, getDialogTitle, getDirectory, getFileChooser, getFileName, getFileView, getGoHomeAction, getModel, getNewFolderAction, getUpdateAction, installComponents, installDefaults, installIcons, installListeners, installStrings, installUI, isDirectorySelected, rescanCurrentDirectory, setDirectory, setFileName, uninstallComponents, uninstallDefaults, uninstallIcons, uninstallListeners, uninstallStrings, uninstallUI`
Modifier and Type
Method
Description
`void`
`clearIconCache()`
Clears the icon cache.
`protected MouseListener`
`createDoubleClickListener(JFileChooser fc, JList<?> list)`
Creates a double click listener.
`protected void`
`createModel()`
Creates the model.
`PropertyChangeListener`
`createPropertyChangeListener(JFileChooser fc)`
Creates the property change listener.
`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.
`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`
`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, 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.
`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.

## Constructor Details

### MetalFileChooserUI

public MetalFileChooserUI(JFileChooser filechooser)
Constructs a new instance of `MetalFileChooserUI`.

Parameters:
  `filechooser` - a `JFileChooser`

## Method Details

### createUI

public static ComponentUI createUI(JComponent c)
Constructs a new instance of `MetalFileChooserUI`.

Parameters:
  `c` - a component
Returns:
  a new instance of `MetalFileChooserUI`

### getButtonPanel

protected JPanel getButtonPanel()
Returns the button panel.

Returns:
  the button panel

### getBottomPanel

protected JPanel getBottomPanel()
Returns the bottom panel.

Returns:
  the bottom panel

### getActionMap

protected ActionMap getActionMap()
Returns an instance of `ActionMap`.

Returns:
  an instance of `ActionMap`

### createActionMap

protected ActionMap createActionMap()
Constructs an instance of `ActionMap`.

Returns:
  an instance of `ActionMap`

### createList

protected JPanel createList(JFileChooser fc)
Constructs a details view.

Parameters:
  `fc` - a `JFileChooser`
Returns:
  the list

### createDetailsView

protected JPanel createDetailsView(JFileChooser fc)
Constructs a details view.

Parameters:
  `fc` - a `JFileChooser`
Returns:
  the details view

### createListSelectionListener

public ListSelectionListener createListSelectionListener(JFileChooser fc)
Creates a selection listener for the list of files and directories.

Overrides:
  `createListSelectionListener` in class `BasicFileChooserUI`
Parameters:
  `fc` - a `JFileChooser`
Returns:
  a `ListSelectionListener`

### getPreferredSize

public Dimension getPreferredSize(JComponent c)
Returns the preferred size of the specified `JFileChooser`. The preferred size is at least as large, in both height and width, as the preferred size recommended by the file chooser's layout manager.

Overrides:
  `getPreferredSize` in class `ComponentUI`
Parameters:
  `c` - a `JFileChooser`
Returns:
  a `Dimension` specifying the preferred width and height of the file chooser
See Also:
  - `JComponent.getPreferredSize()`
  - `LayoutManager.preferredLayoutSize(Container)`

### getMinimumSize

public Dimension getMinimumSize(JComponent c)
Returns the minimum size of the `JFileChooser`.

Overrides:
  `getMinimumSize` in class `ComponentUI`
Parameters:
  `c` - a `JFileChooser`
Returns:
  a `Dimension` specifying the minimum width and height of the file chooser
See Also:
  - `JComponent.getMinimumSize()`
  - `LayoutManager.minimumLayoutSize(Container)`
  - `ComponentUI.getPreferredSize(JComponent)`

### getMaximumSize

public Dimension getMaximumSize(JComponent c)
Returns the maximum size of the `JFileChooser`.

Overrides:
  `getMaximumSize` in class `ComponentUI`
Parameters:
  `c` - a `JFileChooser`
Returns:
  a `Dimension` specifying the maximum width and height of the file chooser
See Also:
  - `JComponent.getMaximumSize()`
  - `LayoutManager2.maximumLayoutSize(Container)`

### removeControlButtons

protected void removeControlButtons()
Removes control buttons from bottom panel.

### addControlButtons

protected void addControlButtons()
Adds control buttons to bottom panel.

### setDirectorySelected

protected void setDirectorySelected(boolean directorySelected)
Property to remember whether a directory is currently selected in the UI. This is normally called by the UI on a selection event.

Overrides:
  `setDirectorySelected` in class `BasicFileChooserUI`
Parameters:
  `directorySelected` - if a directory is currently selected.
Since:
  1.4

### getDirectoryName

public String getDirectoryName()
Returns the directory name.

Overrides:
  `getDirectoryName` in class `BasicFileChooserUI`
Returns:
  the directory name

### setDirectoryName

public void setDirectoryName(String dirname)
Sets the directory name.

Overrides:
  `setDirectoryName` in class `BasicFileChooserUI`
Parameters:
  `dirname` - the directory name

### createDirectoryComboBoxModel

protected MetalFileChooserUI.DirectoryComboBoxModel createDirectoryComboBoxModel(JFileChooser fc)
Constructs a new instance of `DataModel` for `DirectoryComboBox`.

Parameters:
  `fc` - a `JFileChooser`
Returns:
  a new instance of `DataModel` for `DirectoryComboBox`

### createFilterComboBoxRenderer

protected MetalFileChooserUI.FilterComboBoxRenderer createFilterComboBoxRenderer()
Constructs a `Renderer` for types `ComboBox`.

Returns:
  a `Renderer` for types `ComboBox`

### createFilterComboBoxModel

protected MetalFileChooserUI.FilterComboBoxModel createFilterComboBoxModel()
Constructs a `DataModel` for types `ComboBox`.

Returns:
  a `DataModel` for types `ComboBox`

### valueChanged

public void valueChanged(ListSelectionEvent e)
Invokes when `ListSelectionEvent` occurs.

Parameters:
  `e` - an instance of `ListSelectionEvent`