javax.swing.plaf.basic

Class BasicFileChooserUI

Known Direct 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 Icon
upFolderIcon
An icon for the "up folder" 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.

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.FileChooserUI

ensureFileIsVisible, getAcceptAllFileFilter, getApproveButtonText, getDialogTitle, getFileView, rescanCurrentDirectory

Methods inherited from class javax.swing.plaf.ComponentUI

contains, createUI, getAccessibleChild, getAccessibleChildrenCount, getMaximumSize, getMinimumSize, getPreferredSize, installUI, paint, uninstallUI, update

Methods inherited from class java.lang.Object

clone, equals, extends Object> getClass, finalize, hashCode, notify, notifyAll, toString, wait, wait, wait

Field Details

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.

upFolderIcon

protected Icon upFolderIcon
An icon for the "up folder" 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.

Constructor Details

BasicFileChooserUI

public BasicFileChooserUI(JFileChooser b)
Creates a new BasicFileChooserUI object.
Parameters:
b - the file chooser component.

Method Details

clearIconCache

public void clearIconCache()
Clears the icon cache.

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.

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.

createModel

protected void createModel()
Creates a new 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.

createUI

public static ComponentUI createUI(JComponent c)
Returns a UI delegate for the given component.
Overrides:
createUI in interface ComponentUI
Parameters:
c - the component (should be a JFileChooser).
Returns:
A new UI delegate.

ensureFileIsVisible

public void ensureFileIsVisible(JFileChooser fc,
                                File f)
NOT YET IMPLEMENTED.
Overrides:
ensureFileIsVisible in interface FileChooserUI
Parameters:
fc - the file chooser.
f - the file.

getAcceptAllFileFilter

public FileFilter getAcceptAllFileFilter(JFileChooser fc)
Returns the "accept all" file filter.
Overrides:
getAcceptAllFileFilter in interface FileChooserUI
Parameters:
fc - the file chooser component.
Returns:
The "accept all" file filter.

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.

getApproveButtonMnemonic

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

getApproveButtonText

public String getApproveButtonText(JFileChooser fc)
Returns the approve button text.
Overrides:
getApproveButtonText in interface FileChooserUI
Parameters:
fc - the file chooser (null not permitted).
Returns:
The approve button text.

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.

getApproveSelectionAction

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

getCancelSelectionAction

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

getChangeToParentDirectoryAction

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

getDialogTitle

public String getDialogTitle(JFileChooser fc)
Returns the dialog title.
Overrides:
getDialogTitle in interface FileChooserUI
Parameters:
fc - the file chooser (null not permitted).
Returns:
The dialog title.

getDirectory

protected File getDirectory()
Returns the current directory.
Returns:
The current directory.

getDirectoryName

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

getFileChooser

public JFileChooser getFileChooser()
Returns the JFileChooser component that this UI delegate represents.
Returns:
The component represented by this UI delegate.

getFileName

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

getFileView

public FileView getFileView(JFileChooser fc)
Returns the default file view (NOT the file view from the file chooser, if there is one).
Overrides:
getFileView in interface FileChooserUI
Parameters:
fc - the file chooser component.
Returns:
The file view.

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.

getModel

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

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.

getUpdateAction

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

installComponents

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

installDefaults

protected void installDefaults(JFileChooser fc)
Installs the defaults for 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).

installListeners

protected void installListeners(JFileChooser fc)
Installs the listeners required 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.

installUI

public void installUI(JComponent c)
Installs the UI for the specified component.
Overrides:
installUI in interface ComponentUI
Parameters:
c - the component (should be a JFileChooser).

isDirectorySelected

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

rescanCurrentDirectory

public void rescanCurrentDirectory(JFileChooser fc)
Rescans the current directory.
Overrides:
rescanCurrentDirectory in interface FileChooserUI
Parameters:
fc - the file chooser.

setDirectory

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

setDirectoryName

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

setDirectorySelected

protected void setDirectorySelected(boolean selected)
Sets the flag that indicates whether the current directory is selected.
Parameters:
selected - the new flag value.

setFileName

public void setFileName(String filename)
Sets the file name.
Parameters:
filename - the file name.
See Also:
getFileName()

uninstallComponents

public void uninstallComponents(JFileChooser fc)
Uninstalls the components from the file chooser.
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.

uninstallIcons

protected void uninstallIcons(JFileChooser fc)
Uninstalls the icons previously added 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.

uninstallStrings

protected void uninstallStrings(JFileChooser fc)
Uninstalls the strings previously added by this UI delegate.
Parameters:
fc - the file chooser.

uninstallUI

public void uninstallUI(JComponent c)
Uninstalls this UI from the given component.
Overrides:
uninstallUI in interface ComponentUI
Parameters:
c - the component (should be a JFileChooser).

BasicFileChooserUI.java -- Copyright (C) 2005 Free Software Foundation, Inc. This file is part of GNU Classpath. GNU Classpath is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2, or (at your option) any later version. GNU Classpath is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with GNU Classpath; see the file COPYING. If not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. Linking this library statically or dynamically with other modules is making a combined work based on this library. Thus, the terms and conditions of the GNU General Public License cover the whole combination. As a special exception, the copyright holders of this library give you permission to link this library with independent modules to produce an executable, regardless of the license terms of these independent modules, and to copy and distribute the resulting executable under terms of your choice, provided that you also meet, for each linked independent module, the terms and conditions of the license of that module. An independent module is a module which is not derived from or based on this library. If you modify this library, you may extend this exception to your version of the library, but you are not obligated to do so. If you do not wish to do so, delete this exception statement from your version.