javax.swing.plaf.basic
Class BasicFileChooserUI

java.lang.Object
  extended by javax.swing.plaf.ComponentUI
      extended by javax.swing.plaf.FileChooserUI
          extended by javax.swing.plaf.basic.BasicFileChooserUI
Direct Known Subclasses:
MetalFileChooserUI

public class BasicFileChooserUI
extends FileChooserUI

A UI delegate for the JFileChooser component under the BasicLookAndFeel.


Nested Class Summary
protected  class BasicFileChooserUI.AcceptAllFileFilter
          A file filter that accepts all files.
protected  class BasicFileChooserUI.ApproveSelectionAction
          Handles a user action to approve the dialog selection.
protected  class BasicFileChooserUI.BasicFileView
          Provides presentation information about files and directories.
protected  class BasicFileChooserUI.CancelSelectionAction
          Handles an action to cancel the file chooser.
protected  class BasicFileChooserUI.ChangeToParentDirectoryAction
          An action to handle changes to the parent directory (for example, via a click on the "up folder" button).
protected  class BasicFileChooserUI.DoubleClickListener
          A mouse listener that handles double-click events.
protected  class BasicFileChooserUI.GoHomeAction
          An action that changes the file chooser to display the user's home directory.
protected  class BasicFileChooserUI.NewFolderAction
          An action that handles the creation of a new folder/directory.
protected  class BasicFileChooserUI.SelectionListener
          A listener for selection events in the file list.
protected  class BasicFileChooserUI.UpdateAction
          DOCUMENT ME!
 
Field Summary
protected  int cancelButtonMnemonic
          The localised mnemonic for the cancel button.
protected  String cancelButtonText
          The localised text for the cancel button.
protected  String cancelButtonToolTipText
          The localised tool tip text for the cancel button.
protected  Icon computerIcon
          An icon representing a computer.
protected  Icon detailsViewIcon
          An icon for the "details view" button.
protected  Icon directoryIcon
          An icon representing a directory.
protected  int directoryOpenButtonMnemonic
          The localised Mnemonic for the open button.
protected  String directoryOpenButtonText
          The localised text for the open button.
protected  String directoryOpenButtonToolTipText
          The localised tool tip text for the open button.
protected  Icon fileIcon
          An icon representing a file.
protected  Icon floppyDriveIcon
          An icon representing a floppy drive.
protected  Icon hardDriveIcon
          An icon representing a hard drive.
protected  int helpButtonMnemonic
          The localised mnemonic for the "help" button.
protected  String helpButtonText
          The localised text for the "help" button.
protected  String helpButtonToolTipText
          The localised tool tip text for the help button.
protected  Icon homeFolderIcon
          An icon representing the user's home folder.
protected  Icon listViewIcon
          An icon for the "list view" button.
protected  Icon newFolderIcon
          An icon for the "new folder" button.
protected  int openButtonMnemonic
          The localised mnemonic for the "open" button.
protected  String openButtonText
          The localised text for the "open" button.
protected  String openButtonToolTipText
          The localised tool tip text for the "open" button.
protected  int saveButtonMnemonic
          The localised mnemonic for the "save" button.
protected  String saveButtonText
          The localised text for the "save" button.
protected  String saveButtonToolTipText
          The localised tool tip text for the save button.
protected  int updateButtonMnemonic
          The localised mnemonic for the "update" button.
protected  String updateButtonText
          The localised text for the "update" button.
protected  String updateButtonToolTipText
          The localised tool tip text for the "update" button.
protected  Icon upFolderIcon
          An icon for the "up folder" button.
 
Constructor Summary
BasicFileChooserUI(JFileChooser b)
          Creates a new BasicFileChooserUI object.
 
Method Summary
 void clearIconCache()
          Clears the icon cache.
protected  MouseListener createDoubleClickListener(JFileChooser fc, JList list)
          Creates a new listener to handle double-click events.
 ListSelectionListener createListSelectionListener(JFileChooser fc)
          Creates a new listener to handle selections in the file list.
protected  void createModel()
          Creates a new directory model.
 PropertyChangeListener createPropertyChangeListener(JFileChooser fc)
          Creates a listener to handle changes to the properties of the given file chooser component.
static ComponentUI createUI(JComponent c)
          Returns a UI delegate for the given component.
 void ensureFileIsVisible(JFileChooser fc, File f)
          NOT YET IMPLEMENTED.
 FileFilter getAcceptAllFileFilter(JFileChooser fc)
          Returns the "accept all" file filter.
 JPanel getAccessoryPanel()
          Returns the optional accessory panel.
protected  JButton getApproveButton(JFileChooser fc)
          Returns the approve (open or save) button for the dialog.
 int getApproveButtonMnemonic(JFileChooser fc)
          Returns the approve button mnemonic.
 String getApproveButtonText(JFileChooser fc)
          Returns the approve button text.
 String getApproveButtonToolTipText(JFileChooser fc)
          Returns the tool tip text for the approve (open/save) button.
 Action getApproveSelectionAction()
          Returns the action that handles events for the "approve" button.
 Action getCancelSelectionAction()
          Returns the action that handles events for the "cancel" button.
 Action getChangeToParentDirectoryAction()
          Returns the action that handles events for the "up folder" control button.
 String getDialogTitle(JFileChooser fc)
          Returns the dialog title.
protected  File getDirectory()
          Returns the current directory.
 String getDirectoryName()
          Returns the current directory name.
 JFileChooser getFileChooser()
          Returns the JFileChooser component that this UI delegate represents.
 String getFileName()
          Returns the current file name.
 FileView getFileView(JFileChooser fc)
          Returns the default file view (NOT the file view from the file chooser, if there is one).
 Action getGoHomeAction()
          Creates and returns a new action that will be used with the "home folder" button.
 BasicDirectoryModel getModel()
          Returns the directory model.
 Action getNewFolderAction()
          Creates and returns a new action that will be used with the "new folder" button.
 Action getUpdateAction()
          Returns the update action (an instance of BasicFileChooserUI.UpdateAction).
 void installComponents(JFileChooser fc)
          Creates and install the subcomponents for the file chooser.
protected  void installDefaults(JFileChooser fc)
          Installs the defaults for this UI delegate.
protected  void installIcons(JFileChooser fc)
          Installs the icons for this UI delegate.
protected  void installListeners(JFileChooser fc)
          Installs the listeners required by this UI delegate.
protected  void installStrings(JFileChooser fc)
          Installs the strings used by this UI delegate.
 void installUI(JComponent c)
          Installs the UI for the specified component.
protected  boolean isDirectorySelected()
          Returns true if a directory is selected, and false otherwise.
 void rescanCurrentDirectory(JFileChooser fc)
          Rescans the current directory.
protected  void setDirectory(File f)
          Sets the current directory.
 void setDirectoryName(String dirname)
          Sets the directory name (NOT IMPLEMENTED).
protected  void setDirectorySelected(boolean selected)
          Sets the flag that indicates whether the current directory is selected.
 void setFileName(String filename)
          Sets the file name.
 void uninstallComponents(JFileChooser fc)
          Uninstalls the components from the file chooser.
protected  void uninstallDefaults(JFileChooser fc)
          Uninstalls the defaults previously added by this UI delegate.
protected  void uninstallIcons(JFileChooser fc)
          Uninstalls the icons previously added by this UI delegate.
protected  void uninstallListeners(JFileChooser fc)
          Uninstalls the listeners previously installed by this UI delegate.
protected  void uninstallStrings(JFileChooser fc)
          Uninstalls the strings previously added by this UI delegate.
 void uninstallUI(JComponent c)
          Uninstalls this UI from the given component.
 
Methods inherited from class javax.swing.plaf.ComponentUI
contains, getAccessibleChild, getAccessibleChildrenCount, getMaximumSize, getMinimumSize, getPreferredSize, paint, update
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

cancelButtonMnemonic

protected int cancelButtonMnemonic
The localised mnemonic for the cancel button.


cancelButtonText

protected String cancelButtonText
The localised text for the cancel button.


cancelButtonToolTipText

protected String cancelButtonToolTipText
The localised tool tip text for the cancel button.


computerIcon

protected Icon computerIcon
An icon representing a computer.


detailsViewIcon

protected Icon detailsViewIcon
An icon for the "details view" button.


directoryIcon

protected Icon directoryIcon
An icon representing a directory.


directoryOpenButtonMnemonic

protected int directoryOpenButtonMnemonic
The localised Mnemonic for the open button.


directoryOpenButtonText

protected String directoryOpenButtonText
The localised text for the open button.


directoryOpenButtonToolTipText

protected String directoryOpenButtonToolTipText
The localised tool tip text for the open button.


fileIcon

protected Icon fileIcon
An icon representing a file.


floppyDriveIcon

protected Icon floppyDriveIcon
An icon representing a floppy drive.


hardDriveIcon

protected Icon hardDriveIcon
An icon representing a hard drive.


helpButtonMnemonic

protected int helpButtonMnemonic
The localised mnemonic for the "help" button.


helpButtonText

protected String helpButtonText
The localised text for the "help" button.


helpButtonToolTipText

protected String helpButtonToolTipText
The localised tool tip text for the help button.


homeFolderIcon

protected Icon homeFolderIcon
An icon representing the user's home folder.


listViewIcon

protected Icon listViewIcon
An icon for the "list view" button.


newFolderIcon

protected Icon newFolderIcon
An icon for the "new folder" button.


openButtonMnemonic

protected int openButtonMnemonic
The localised mnemonic for the "open" button.


openButtonText

protected String openButtonText
The localised text for the "open" button.


openButtonToolTipText

protected String openButtonToolTipText
The localised tool tip text for the "open" button.


saveButtonMnemonic

protected int saveButtonMnemonic
The localised mnemonic for the "save" button.


saveButtonText

protected String saveButtonText
The localised text for the "save" button.


saveButtonToolTipText

protected String saveButtonToolTipText
The localised tool tip text for the save button.


updateButtonMnemonic

protected int updateButtonMnemonic
The localised mnemonic for the "update" button.


updateButtonText

protected String updateButtonText
The localised text for the "update" button.


updateButtonToolTipText

protected String updateButtonToolTipText
The localised tool tip text for the "update" button.


upFolderIcon

protected Icon upFolderIcon
An icon for the "up folder" button.

Constructor Detail

BasicFileChooserUI

public BasicFileChooserUI(JFileChooser b)
Creates a new BasicFileChooserUI object.

Parameters:
b - the file chooser component.
Method Detail

createUI

public static ComponentUI createUI(JComponent c)
Returns a UI delegate for the given component.

Parameters:
c - the component (should be a JFileChooser).
Returns:
A new UI delegate.

installUI

public void installUI(JComponent c)
Installs the UI for the specified component.

Overrides:
installUI in class ComponentUI
Parameters:
c - the component (should be a JFileChooser).
See Also:
ComponentUI.uninstallUI(javax.swing.JComponent), JComponent.setUI(javax.swing.plaf.ComponentUI), JComponent.updateUI()

uninstallUI

public void uninstallUI(JComponent c)
Uninstalls this UI from the given component.

Overrides:
uninstallUI in class ComponentUI
Parameters:
c - the component (should be a JFileChooser).
See Also:
ComponentUI.installUI(javax.swing.JComponent), JComponent.setUI(javax.swing.plaf.ComponentUI), JComponent.updateUI()

installComponents

public void installComponents(JFileChooser fc)
Creates and install the subcomponents for the file chooser.

Parameters:
fc - the file chooser.

uninstallComponents

public void uninstallComponents(JFileChooser fc)
Uninstalls the components from the file chooser.

Parameters:
fc - the file chooser.

installListeners

protected void installListeners(JFileChooser fc)
Installs the listeners required by this UI delegate.

Parameters:
fc - the file chooser.

uninstallListeners

protected void uninstallListeners(JFileChooser fc)
Uninstalls the listeners previously installed by this UI delegate.

Parameters:
fc - the file chooser.

installDefaults

protected void installDefaults(JFileChooser fc)
Installs the defaults for this UI delegate.

Parameters:
fc - the file chooser.

uninstallDefaults

protected void uninstallDefaults(JFileChooser fc)
Uninstalls the defaults previously added by this UI delegate.

Parameters:
fc - the file chooser.

installIcons

protected void installIcons(JFileChooser fc)
Installs the icons for this UI delegate.

Parameters:
fc - the file chooser (ignored).

uninstallIcons

protected void uninstallIcons(JFileChooser fc)
Uninstalls the icons previously added by this UI delegate.

Parameters:
fc - the file chooser.

installStrings

protected void installStrings(JFileChooser fc)
Installs the strings used by this UI delegate.

Parameters:
fc - the file chooser.

uninstallStrings

protected void uninstallStrings(JFileChooser fc)
Uninstalls the strings previously added by this UI delegate.

Parameters:
fc - the file chooser.

createModel

protected void createModel()
Creates a new directory model.


getModel

public BasicDirectoryModel getModel()
Returns the directory model.

Returns:
The directory model.

createPropertyChangeListener

public PropertyChangeListener createPropertyChangeListener(JFileChooser fc)
Creates a listener to handle changes to the properties of the given file chooser component.

Parameters:
fc - the file chooser component.
Returns:
A new listener.

getFileName

public String getFileName()
Returns the current file name.

Returns:
The current file name.

getDirectoryName

public String getDirectoryName()
Returns the current directory name.

Returns:
The directory name.
See Also:
setDirectoryName(String)

setFileName

public void setFileName(String filename)
Sets the file name.

Parameters:
filename - the file name.
See Also:
getFileName()

setDirectoryName

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

Parameters:
dirname - the directory name.
See Also:
getDirectoryName()

rescanCurrentDirectory

public void rescanCurrentDirectory(JFileChooser fc)
Rescans the current directory.

Specified by:
rescanCurrentDirectory in class FileChooserUI
Parameters:
fc - the file chooser.

ensureFileIsVisible

public void ensureFileIsVisible(JFileChooser fc,
                                File f)
NOT YET IMPLEMENTED.

Specified by:
ensureFileIsVisible in class FileChooserUI
Parameters:
fc - the file chooser.
f - the file.

getFileChooser

public JFileChooser getFileChooser()
Returns the JFileChooser component that this UI delegate represents.

Returns:
The component represented by this UI delegate.

getAccessoryPanel

public JPanel getAccessoryPanel()
Returns the optional accessory panel.

Returns:
The optional accessory panel.

getApproveButton

protected JButton getApproveButton(JFileChooser fc)
Returns the approve (open or save) button for the dialog.

Parameters:
fc - the file chooser.
Returns:
The button.

getApproveButtonToolTipText

public String getApproveButtonToolTipText(JFileChooser fc)
Returns the tool tip text for the approve (open/save) button. This first checks the file chooser to see if a value has been explicitly set - if not, a default value appropriate for the type of file chooser is returned.

Parameters:
fc - the file chooser.
Returns:
The tool tip text.

clearIconCache

public void clearIconCache()
Clears the icon cache.


createListSelectionListener

public ListSelectionListener createListSelectionListener(JFileChooser fc)
Creates a new listener to handle selections in the file list.

Parameters:
fc - the file chooser component.
Returns:
A new instance of BasicFileChooserUI.SelectionListener.

createDoubleClickListener

protected MouseListener createDoubleClickListener(JFileChooser fc,
                                                  JList list)
Creates a new listener to handle double-click events.

Parameters:
fc - the file chooser component.
list - the list.
Returns:
A new instance of BasicFileChooserUI.DoubleClickListener.

isDirectorySelected

protected boolean isDirectorySelected()
Returns true if a directory is selected, and false otherwise.

Returns:
A boolean.

setDirectorySelected

protected void setDirectorySelected(boolean selected)
Sets the flag that indicates whether the current directory is selected.

Parameters:
selected - the new flag value.

getDirectory

protected File getDirectory()
Returns the current directory.

Returns:
The current directory.

setDirectory

protected void setDirectory(File f)
Sets the current directory.

Parameters:
f - the directory.

getAcceptAllFileFilter

public FileFilter getAcceptAllFileFilter(JFileChooser fc)
Returns the "accept all" file filter.

Specified by:
getAcceptAllFileFilter in class FileChooserUI
Parameters:
fc - the file chooser component.
Returns:
The "accept all" file filter.
See Also:
JFileChooser.getAcceptAllFileFilter(), FileFilter.getDescription()

getFileView

public FileView getFileView(JFileChooser fc)
Returns the default file view (NOT the file view from the file chooser, if there is one).

Specified by:
getFileView in class FileChooserUI
Parameters:
fc - the file chooser component.
Returns:
The file view.
See Also:
JFileChooser.getFileView()

getDialogTitle

public String getDialogTitle(JFileChooser fc)
Returns the dialog title.

Specified by:
getDialogTitle in class FileChooserUI
Parameters:
fc - the file chooser (null not permitted).
Returns:
The dialog title.
See Also:
JFileChooser.getDialogTitle()

getApproveButtonMnemonic

public int getApproveButtonMnemonic(JFileChooser fc)
Returns the approve button mnemonic.

Parameters:
fc - the file chooser (null not permitted).
Returns:
The approve button mnemonic.
See Also:
JFileChooser.getApproveButtonMnemonic()

getApproveButtonText

public String getApproveButtonText(JFileChooser fc)
Returns the approve button text.

Specified by:
getApproveButtonText in class FileChooserUI
Parameters:
fc - the file chooser (null not permitted).
Returns:
The approve button text.
See Also:
JFileChooser.getApproveButtonText()

getNewFolderAction

public Action getNewFolderAction()
Creates and returns a new action that will be used with the "new folder" button.

Returns:
A new instance of BasicFileChooserUI.NewFolderAction.

getGoHomeAction

public Action getGoHomeAction()
Creates and returns a new action that will be used with the "home folder" button.

Returns:
A new instance of BasicFileChooserUI.GoHomeAction.

getChangeToParentDirectoryAction

public Action getChangeToParentDirectoryAction()
Returns the action that handles events for the "up folder" control button.

Returns:
An instance of BasicFileChooserUI.ChangeToParentDirectoryAction.

getApproveSelectionAction

public Action getApproveSelectionAction()
Returns the action that handles events for the "approve" button.

Returns:
An instance of BasicFileChooserUI.ApproveSelectionAction.

getCancelSelectionAction

public Action getCancelSelectionAction()
Returns the action that handles events for the "cancel" button.

Returns:
An instance of BasicFileChooserUI.CancelSelectionAction.

getUpdateAction

public Action getUpdateAction()
Returns the update action (an instance of BasicFileChooserUI.UpdateAction).

Returns:
An action.