FileDocCategorySizeDatePackage
WindowsFileChooserUI.javaAPI DocJava SE 6 API40027Tue Jun 10 00:21:58 BST 2008com.sun.java.swing.plaf.windows

WindowsFileChooserUI

public class WindowsFileChooserUI extends BasicFileChooserUI
Windows L&F implementation of a FileChooser.
version
1.102 06/04/07
author
Jeff Dinkins

Fields Summary
private static final String
OS_VERSION
private JPanel
centerPanel
private JLabel
lookInLabel
private JComboBox
directoryComboBox
private DirectoryComboBoxModel
directoryComboBoxModel
private ActionListener
directoryComboBoxAction
private FilterComboBoxModel
filterComboBoxModel
private JTextField
filenameTextField
private JToggleButton
listViewButton
private JToggleButton
detailsViewButton
private FilePane
filePane
private WindowsPlacesBar
placesBar
private boolean
useShellFolder
private JButton
approveButton
private JButton
cancelButton
private JPanel
buttonPanel
private JPanel
bottomPanel
private JComboBox
filterComboBox
private static final Dimension
hstrut10
private static final Dimension
vstrut4
private static final Dimension
vstrut6
private static final Dimension
vstrut8
private static final Insets
shrinkwrap
private static int
PREF_WIDTH
private static int
PREF_HEIGHT
private static Dimension
PREF_SIZE
private static int
MIN_WIDTH
private static int
MIN_HEIGHT
private static Dimension
MIN_SIZE
private static int
LIST_PREF_WIDTH
private static int
LIST_PREF_HEIGHT
private static Dimension
LIST_PREF_SIZE
private int
lookInLabelMnemonic
private String
lookInLabelText
private String
saveInLabelText
private int
fileNameLabelMnemonic
private String
fileNameLabelText
private int
filesOfTypeLabelMnemonic
private String
filesOfTypeLabelText
private String
upFolderToolTipText
private String
upFolderAccessibleName
private String
homeFolderToolTipText
private String
homeFolderAccessibleName
private String
newFolderToolTipText
private String
newFolderAccessibleName
private String
listViewButtonToolTipText
private String
listViewButtonAccessibleName
private String
detailsViewButtonToolTipText
private String
detailsViewButtonAccessibleName
private BasicFileView
fileView
static final int
space
Constructors Summary
public WindowsFileChooserUI(JFileChooser filechooser)

	super(filechooser);
    
Methods Summary
protected voidaddControlButtons()

	getBottomPanel().add(getButtonPanel());
    
protected javax.swing.ActionMapcreateActionMap()

        ActionMap map = new ActionMapUIResource();
	FilePane.addActionsToMap(map, filePane.getActions());
        return map;
    
protected javax.swing.JPanelcreateDetailsView(javax.swing.JFileChooser fc)

	return filePane.createDetailsView();
    
protected com.sun.java.swing.plaf.windows.WindowsFileChooserUI$DirectoryComboBoxModelcreateDirectoryComboBoxModel(javax.swing.JFileChooser fc)

	return new DirectoryComboBoxModel();
    
protected com.sun.java.swing.plaf.windows.WindowsFileChooserUI$DirectoryComboBoxRenderercreateDirectoryComboBoxRenderer(javax.swing.JFileChooser fc)

	return new DirectoryComboBoxRenderer();
    
protected com.sun.java.swing.plaf.windows.WindowsFileChooserUI$FilterComboBoxModelcreateFilterComboBoxModel()

	return new FilterComboBoxModel();
    
protected com.sun.java.swing.plaf.windows.WindowsFileChooserUI$FilterComboBoxRenderercreateFilterComboBoxRenderer()

	return new FilterComboBoxRenderer();
    
protected javax.swing.JPanelcreateList(javax.swing.JFileChooser fc)

	return filePane.createList();
    
public javax.swing.event.ListSelectionListenercreateListSelectionListener(javax.swing.JFileChooser fc)
Creates a selection listener for the list of files and directories.

param
fc a JFileChooser
return
a ListSelectionListener

	return super.createListSelectionListener(fc);
    
public java.beans.PropertyChangeListenercreatePropertyChangeListener(javax.swing.JFileChooser fc)

	return new PropertyChangeListener() {
	    public void propertyChange(PropertyChangeEvent e) {
		String s = e.getPropertyName();
		if(s.equals(JFileChooser.SELECTED_FILE_CHANGED_PROPERTY)) {
		    doSelectedFileChanged(e);
		} else if (s.equals(JFileChooser.SELECTED_FILES_CHANGED_PROPERTY)) {
		    doSelectedFilesChanged(e);
		} else if(s.equals(JFileChooser.DIRECTORY_CHANGED_PROPERTY)) {
		    doDirectoryChanged(e);
		} else if(s.equals(JFileChooser.FILE_FILTER_CHANGED_PROPERTY)) {
		    doFilterChanged(e);
		} else if(s.equals(JFileChooser.FILE_SELECTION_MODE_CHANGED_PROPERTY)) {
		    doFileSelectionModeChanged(e);
		} else if(s.equals(JFileChooser.ACCESSORY_CHANGED_PROPERTY)) {
		    doAccessoryChanged(e);
		} else if (s.equals(JFileChooser.APPROVE_BUTTON_TEXT_CHANGED_PROPERTY) ||
			   s.equals(JFileChooser.APPROVE_BUTTON_TOOL_TIP_TEXT_CHANGED_PROPERTY)) { 
		    doApproveButtonTextChanged(e);
		} else if(s.equals(JFileChooser.DIALOG_TYPE_CHANGED_PROPERTY)) {
		    doDialogTypeChanged(e);
		} else if(s.equals(JFileChooser.APPROVE_BUTTON_MNEMONIC_CHANGED_PROPERTY)) {
		    doApproveButtonMnemonicChanged(e);
		} else if(s.equals(JFileChooser.CONTROL_BUTTONS_ARE_SHOWN_CHANGED_PROPERTY)) {
		    doControlButtonsChanged(e);
		} else if (s == "FileChooser.useShellFolder") {
		    updateUseShellFolder();
		    doDirectoryChanged(e);
		} else if (s.equals("componentOrientation")) {
		    ComponentOrientation o = (ComponentOrientation)e.getNewValue();
		    JFileChooser cc = (JFileChooser)e.getSource();
		    if (o != (ComponentOrientation)e.getOldValue()) {
			cc.applyComponentOrientation(o);
		    }
		} else if (s.equals("ancestor")) {
		    if (e.getOldValue() == null && e.getNewValue() != null) {
			// Ancestor was added, set initial focus
			filenameTextField.selectAll();
			filenameTextField.requestFocus();
		    }
		}
	    }
	};
    
public static javax.swing.plaf.ComponentUIcreateUI(javax.swing.JComponent c)


    //
    // ComponentUI Interface Implementation methods
    //
         
        return new WindowsFileChooserUI((JFileChooser) c);
    
private voiddoAccessoryChanged(java.beans.PropertyChangeEvent e)

	if(getAccessoryPanel() != null) {
	    if(e.getOldValue() != null) {
		getAccessoryPanel().remove((JComponent) e.getOldValue());
	    }
	    JComponent accessory = (JComponent) e.getNewValue();
	    if(accessory != null) {
		getAccessoryPanel().add(accessory, BorderLayout.CENTER);
	    }
	}
    
private voiddoApproveButtonMnemonicChanged(java.beans.PropertyChangeEvent e)

	approveButton.setMnemonic(getApproveButtonMnemonic(getFileChooser()));
    
private voiddoApproveButtonTextChanged(java.beans.PropertyChangeEvent e)

	JFileChooser chooser = getFileChooser();
	approveButton.setText(getApproveButtonText(chooser));
	approveButton.setToolTipText(getApproveButtonToolTipText(chooser));
	approveButton.setMnemonic(getApproveButtonMnemonic(chooser));
    
private voiddoControlButtonsChanged(java.beans.PropertyChangeEvent e)

	if(getFileChooser().getControlButtonsAreShown()) {
	    addControlButtons();
	} else {
	    removeControlButtons();
	}
    
private voiddoDialogTypeChanged(java.beans.PropertyChangeEvent e)

	JFileChooser chooser = getFileChooser();
	approveButton.setText(getApproveButtonText(chooser));
	approveButton.setToolTipText(getApproveButtonToolTipText(chooser));
	approveButton.setMnemonic(getApproveButtonMnemonic(chooser));
	if (chooser.getDialogType() == JFileChooser.SAVE_DIALOG) {
	    lookInLabel.setText(saveInLabelText);
	} else {
	    lookInLabel.setText(lookInLabelText);
	}
    
private voiddoDirectoryChanged(java.beans.PropertyChangeEvent e)

	JFileChooser fc = getFileChooser();
	FileSystemView fsv = fc.getFileSystemView();

	clearIconCache();
	File currentDirectory = fc.getCurrentDirectory();
	if(currentDirectory != null) {
	    directoryComboBoxModel.addItem(currentDirectory);

	    if (fc.isDirectorySelectionEnabled() && !fc.isFileSelectionEnabled()) {
		if (fsv.isFileSystem(currentDirectory)) {
		    setFileName(currentDirectory.getPath());
		} else {
		    setFileName(null);
		}
	    }
	}
    
private voiddoFileSelectionModeChanged(java.beans.PropertyChangeEvent e)

	clearIconCache();

	JFileChooser fc = getFileChooser();
	File currentDirectory = fc.getCurrentDirectory();
	if (currentDirectory != null
	    && fc.isDirectorySelectionEnabled()
	    && !fc.isFileSelectionEnabled()
	    && fc.getFileSystemView().isFileSystem(currentDirectory)) {

	    setFileName(currentDirectory.getPath());
	} else {
	    setFileName(null);
	}
    
private voiddoFilterChanged(java.beans.PropertyChangeEvent e)

	clearIconCache();
    
private voiddoSelectedFileChanged(java.beans.PropertyChangeEvent e)

	File f = (File) e.getNewValue();
	JFileChooser fc = getFileChooser();
	if (f != null 
	    && ((fc.isFileSelectionEnabled() && !f.isDirectory())
		|| (f.isDirectory() && fc.isDirectorySelectionEnabled()))) {

	    setFileName(fileNameString(f));
	}
    
private voiddoSelectedFilesChanged(java.beans.PropertyChangeEvent e)

	File[] files = (File[]) e.getNewValue();
	JFileChooser fc = getFileChooser();
	if (files != null
	    && files.length > 0
	    && (files.length > 1 || fc.isDirectorySelectionEnabled() || !files[0].isDirectory())) {
	    setFileName(fileNameString(files));
	}
    
public voidensureFileIsVisible(javax.swing.JFileChooser fc, java.io.File f)

	filePane.ensureFileIsVisible(fc, f);
    
private java.lang.StringfileNameString(java.io.File file)

	if (file == null) {
	    return null;
	} else {
	    JFileChooser fc = getFileChooser();
	    if ((fc.isDirectorySelectionEnabled() && !fc.isFileSelectionEnabled()) || 
	        (fc.isDirectorySelectionEnabled() && fc.isFileSelectionEnabled() && fc.getFileSystemView().isFileSystemRoot(file))){
		return file.getPath();
	    } else {
		return file.getName();
	    }
	}
    
private java.lang.StringfileNameString(java.io.File[] files)

	StringBuffer buf = new StringBuffer();
	for (int i = 0; files != null && i < files.length; i++) {
	    if (i > 0) {
		buf.append(" ");
	    }
	    if (files.length > 1) {
		buf.append("\"");
	    }
	    buf.append(fileNameString(files[i]));
	    if (files.length > 1) {
		buf.append("\"");
	    }
	}
	return buf.toString();
    
protected javax.swing.ActionMapgetActionMap()

        return createActionMap();
    
protected javax.swing.JButtongetApproveButton(javax.swing.JFileChooser fc)

	return approveButton;
    
protected javax.swing.JPanelgetBottomPanel()

	if(bottomPanel == null) {
	    bottomPanel = new JPanel();
	}
	return bottomPanel;
    
protected javax.swing.JPanelgetButtonPanel()

	if(buttonPanel == null) {
	    buttonPanel = new JPanel();
	}
	return buttonPanel;
    
public java.lang.StringgetDirectoryName()

	// PENDING(jeff) - get the name from the directory combobox
	return null;
    
public java.lang.StringgetFileName()

	if(filenameTextField != null) {
	    return filenameTextField.getText();
	} else {
	    return null;
	}
    
public javax.swing.filechooser.FileViewgetFileView(javax.swing.JFileChooser fc)

	return fileView;
    
public java.awt.DimensiongetMaximumSize(javax.swing.JComponent c)
Returns the maximum size of the JFileChooser.

param
c a JFileChooser
return
a Dimension specifying the maximum width and height of the file chooser

	return new Dimension(Integer.MAX_VALUE, Integer.MAX_VALUE);
    
public java.awt.DimensiongetMinimumSize(javax.swing.JComponent c)
Returns the minimum size of the JFileChooser.

param
c a JFileChooser
return
a Dimension specifying the minimum width and height of the file chooser

	return MIN_SIZE;
    
public java.awt.DimensiongetPreferredSize(javax.swing.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.

param
c a JFileChooser
return
a Dimension specifying the preferred width and height of the file chooser

	int prefWidth = PREF_SIZE.width;
	Dimension d = c.getLayout().preferredLayoutSize(c);
	if (d != null) {
	    return new Dimension(d.width < prefWidth ? prefWidth : d.width,
				 d.height < PREF_SIZE.height ? PREF_SIZE.height : d.height);
	} else {
	    return new Dimension(prefWidth, PREF_SIZE.height);
	}
    
public voidinstallComponents(javax.swing.JFileChooser fc)

	filePane = new FilePane(new WindowsFileChooserUIAccessor());
	fc.addPropertyChangeListener(filePane);

	FileSystemView fsv = fc.getFileSystemView();

	fc.setBorder(new EmptyBorder(4, 10, 10, 10));
	fc.setLayout(new BorderLayout(8, 8));

	updateUseShellFolder();

	// ********************************* //
	// **** Construct the top panel **** //
	// ********************************* //

	// Directory manipulation buttons
	JToolBar topPanel = new JToolBar();
	topPanel.setFloatable(false);
	if (OS_VERSION.compareTo("4.9") >= 0) {	// Windows Me/2000 and later (4.90/5.0)
	    topPanel.putClientProperty("JToolBar.isRollover", Boolean.TRUE);
	}

	// Add the top panel to the fileChooser
	fc.add(topPanel, BorderLayout.NORTH);

	// ComboBox Label
     	lookInLabel = new JLabel(lookInLabelText, JLabel.TRAILING) {
	    public Dimension getPreferredSize() {
		return getMinimumSize();
	    }

	    public Dimension getMinimumSize() {
		Dimension d = super.getPreferredSize();
		if (placesBar != null) {
		    d.width = Math.max(d.width, placesBar.getWidth());
		}
		return d;
	    }
	};
     	lookInLabel.setDisplayedMnemonic(lookInLabelMnemonic);
	lookInLabel.setAlignmentX(JComponent.LEFT_ALIGNMENT);
	lookInLabel.setAlignmentY(JComponent.CENTER_ALIGNMENT);
	topPanel.add(lookInLabel);
	topPanel.add(Box.createRigidArea(new Dimension(8,0)));

	// CurrentDir ComboBox
	directoryComboBox = new JComboBox() {
	    public Dimension getMinimumSize() {
		Dimension d = super.getMinimumSize();
		d.width = 60;
		return d;
	    }

	    public Dimension getPreferredSize() {
		Dimension d = super.getPreferredSize();
		// Must be small enough to not affect total width.
		d.width = 150;
		return d;
	    }
	};
	directoryComboBox.putClientProperty( "JComboBox.lightweightKeyboardNavigation", "Lightweight" );
	lookInLabel.setLabelFor(directoryComboBox);
	directoryComboBoxModel = createDirectoryComboBoxModel(fc);
	directoryComboBox.setModel(directoryComboBoxModel);
	directoryComboBox.addActionListener(directoryComboBoxAction);
	directoryComboBox.setRenderer(createDirectoryComboBoxRenderer(fc));
	directoryComboBox.setAlignmentX(JComponent.LEFT_ALIGNMENT);
	directoryComboBox.setAlignmentY(JComponent.CENTER_ALIGNMENT);
	directoryComboBox.setMaximumRowCount(8);

	topPanel.add(directoryComboBox);
	topPanel.add(Box.createRigidArea(hstrut10));

	// Up Button
	JButton upFolderButton = new JButton(getChangeToParentDirectoryAction());
	upFolderButton.setText(null);
	upFolderButton.setIcon(upFolderIcon);
     	upFolderButton.setToolTipText(upFolderToolTipText);
        upFolderButton.putClientProperty(AccessibleContext.ACCESSIBLE_NAME_PROPERTY,
                                         upFolderAccessibleName);
        upFolderButton.putClientProperty(WindowsLookAndFeel.HI_RES_DISABLED_ICON_CLIENT_KEY,
                                         Boolean.TRUE);
	upFolderButton.setAlignmentX(JComponent.LEFT_ALIGNMENT);
	upFolderButton.setAlignmentY(JComponent.CENTER_ALIGNMENT);
	upFolderButton.setMargin(shrinkwrap);
	upFolderButton.setFocusPainted(false);
	topPanel.add(upFolderButton);
	if (OS_VERSION.compareTo("4.9") < 0) {	// Before Windows Me/2000 (4.90/5.0)
	    topPanel.add(Box.createRigidArea(hstrut10));
	}

	JButton b;

	if (OS_VERSION.startsWith("4.1")) {		// Windows 98 (4.10)
	    // Desktop Button
	    File homeDir = fsv.getHomeDirectory();
	    String toolTipText = homeFolderToolTipText;
	    if (fsv.isRoot(homeDir)) {
		toolTipText = getFileView(fc).getName(homeDir); // Probably "Desktop".
	    }
	    b = new JButton(getFileView(fc).getIcon(homeDir));
	    b.setToolTipText(toolTipText);
            b.putClientProperty(AccessibleContext.ACCESSIBLE_NAME_PROPERTY, 
                                toolTipText);
	    b.setAlignmentX(JComponent.LEFT_ALIGNMENT);
	    b.setAlignmentY(JComponent.CENTER_ALIGNMENT);
	    b.setMargin(shrinkwrap);
	    b.setFocusPainted(false);
	    b.addActionListener(getGoHomeAction());
	    topPanel.add(b);
	    topPanel.add(Box.createRigidArea(hstrut10));
	}

	// New Directory Button
	if (!UIManager.getBoolean("FileChooser.readOnly")) {
	    b = new JButton(filePane.getNewFolderAction());
	    b.setText(null);
	    b.setIcon(newFolderIcon);
	    b.setToolTipText(newFolderToolTipText);
            b.putClientProperty(AccessibleContext.ACCESSIBLE_NAME_PROPERTY,
                                newFolderAccessibleName);
            b.putClientProperty(WindowsLookAndFeel.HI_RES_DISABLED_ICON_CLIENT_KEY,
                                Boolean.TRUE);
	    b.setAlignmentX(JComponent.LEFT_ALIGNMENT);
	    b.setAlignmentY(JComponent.CENTER_ALIGNMENT);
	    b.setMargin(shrinkwrap);
	    b.setFocusPainted(false);
	    topPanel.add(b);
	}
	if (OS_VERSION.compareTo("4.9") < 0) {	// Before Windows Me/2000 (4.90/5.0)
	    topPanel.add(Box.createRigidArea(hstrut10));
	}

	// View button group
	ButtonGroup viewButtonGroup = new ButtonGroup();

	// List Button
	listViewButton = new JToggleButton(listViewIcon);
     	listViewButton.setToolTipText(listViewButtonToolTipText);
        listViewButton.putClientProperty(AccessibleContext.ACCESSIBLE_NAME_PROPERTY,
                                         listViewButtonAccessibleName);
        listViewButton.putClientProperty(WindowsLookAndFeel.HI_RES_DISABLED_ICON_CLIENT_KEY,
                                         Boolean.TRUE);
	listViewButton.setFocusPainted(false);
	listViewButton.setSelected(true);
	listViewButton.setAlignmentX(JComponent.LEFT_ALIGNMENT);
	listViewButton.setAlignmentY(JComponent.CENTER_ALIGNMENT);
	listViewButton.setMargin(shrinkwrap);
	listViewButton.addActionListener(filePane.getViewTypeAction(FilePane.VIEWTYPE_LIST));
	topPanel.add(listViewButton);
	viewButtonGroup.add(listViewButton);

	// Details Button
	detailsViewButton = new JToggleButton(detailsViewIcon);
     	detailsViewButton.setToolTipText(detailsViewButtonToolTipText);
        detailsViewButton.putClientProperty(AccessibleContext.ACCESSIBLE_NAME_PROPERTY,
                                            detailsViewButtonAccessibleName);
        detailsViewButton.putClientProperty(WindowsLookAndFeel.HI_RES_DISABLED_ICON_CLIENT_KEY,
                                            Boolean.TRUE);
	detailsViewButton.setFocusPainted(false);
	detailsViewButton.setAlignmentX(JComponent.LEFT_ALIGNMENT);
	detailsViewButton.setAlignmentY(JComponent.CENTER_ALIGNMENT);
	detailsViewButton.setMargin(shrinkwrap);
	detailsViewButton.addActionListener(filePane.getViewTypeAction(FilePane.VIEWTYPE_DETAILS));
	topPanel.add(detailsViewButton);
	viewButtonGroup.add(detailsViewButton);

	topPanel.add(Box.createRigidArea(new Dimension(60, 0)));

	filePane.addPropertyChangeListener(new PropertyChangeListener() {
	    public void propertyChange(PropertyChangeEvent e) {
		if ("viewType".equals(e.getPropertyName())) {
		    int viewType = filePane.getViewType();
		    switch (viewType) {
		      case FilePane.VIEWTYPE_LIST:
			listViewButton.setSelected(true);
			break;

		      case FilePane.VIEWTYPE_DETAILS:
			detailsViewButton.setSelected(true);
			break;
		    }
		}
	    }
	});

	// ************************************** //
	// ******* Add the directory pane ******* //
	// ************************************** //
	centerPanel = new JPanel(new BorderLayout());
	centerPanel.add(getAccessoryPanel(), BorderLayout.AFTER_LINE_ENDS);
	JComponent accessory = fc.getAccessory();
	if(accessory != null) {
	    getAccessoryPanel().add(accessory);
	}
	filePane.setPreferredSize(LIST_PREF_SIZE);
	centerPanel.add(filePane, BorderLayout.CENTER);
	fc.add(centerPanel, BorderLayout.CENTER);

	// ********************************** //
	// **** Construct the bottom panel ** //
	// ********************************** //
	getBottomPanel().setLayout(new BoxLayout(getBottomPanel(), BoxLayout.LINE_AXIS));

	// Add the bottom panel to file chooser
	centerPanel.add(getBottomPanel(), BorderLayout.SOUTH);

	// labels
	JPanel labelPanel = new JPanel();
	labelPanel.setLayout(new BoxLayout(labelPanel, BoxLayout.PAGE_AXIS));
        labelPanel.add(Box.createRigidArea(vstrut4));

     	JLabel fnl = new JLabel(fileNameLabelText);
     	fnl.setDisplayedMnemonic(fileNameLabelMnemonic);
	fnl.setAlignmentY(0);
	labelPanel.add(fnl);

	labelPanel.add(Box.createRigidArea(new Dimension(1,12)));

     	JLabel ftl = new JLabel(filesOfTypeLabelText);
     	ftl.setDisplayedMnemonic(filesOfTypeLabelMnemonic);
	labelPanel.add(ftl);

	getBottomPanel().add(labelPanel);
	getBottomPanel().add(Box.createRigidArea(new Dimension(15, 0)));

	// file entry and filters
	JPanel fileAndFilterPanel = new JPanel();
        fileAndFilterPanel.add(Box.createRigidArea(vstrut8));
	fileAndFilterPanel.setLayout(new BoxLayout(fileAndFilterPanel, BoxLayout.Y_AXIS));


	filenameTextField = new JTextField(35) {
	    public Dimension getMaximumSize() {
		return new Dimension(Short.MAX_VALUE, super.getPreferredSize().height);
	    }
	};

	fnl.setLabelFor(filenameTextField);
        filenameTextField.addFocusListener(
	    new FocusAdapter() {
		public void focusGained(FocusEvent e) {
		    if (!getFileChooser().isMultiSelectionEnabled()) {
			filePane.clearSelection();
		    }
		}
	    }
        );

	if (fc.isMultiSelectionEnabled()) {
	    setFileName(fileNameString(fc.getSelectedFiles()));
	} else {
	    setFileName(fileNameString(fc.getSelectedFile()));
	}

	fileAndFilterPanel.add(filenameTextField);
	fileAndFilterPanel.add(Box.createRigidArea(vstrut8));

	filterComboBoxModel = createFilterComboBoxModel();
	fc.addPropertyChangeListener(filterComboBoxModel);
	filterComboBox = new JComboBox(filterComboBoxModel);
	ftl.setLabelFor(filterComboBox);
	filterComboBox.setRenderer(createFilterComboBoxRenderer());
	fileAndFilterPanel.add(filterComboBox);

	getBottomPanel().add(fileAndFilterPanel);
	getBottomPanel().add(Box.createRigidArea(new Dimension(30, 0)));

	// buttons
	getButtonPanel().setLayout(new BoxLayout(getButtonPanel(), BoxLayout.Y_AXIS));

	approveButton = new JButton(getApproveButtonText(fc)) {
	    public Dimension getMaximumSize() {
		return approveButton.getPreferredSize().width > cancelButton.getPreferredSize().width ?
		       approveButton.getPreferredSize() : cancelButton.getPreferredSize();
	    }
	}; 
	Insets buttonMargin = approveButton.getMargin();
	buttonMargin = new InsetsUIResource(buttonMargin.top,    buttonMargin.left  + 5,
					    buttonMargin.bottom, buttonMargin.right + 5);
	approveButton.setMargin(buttonMargin);
	approveButton.setMnemonic(getApproveButtonMnemonic(fc));
	approveButton.addActionListener(getApproveSelectionAction());
	approveButton.setToolTipText(getApproveButtonToolTipText(fc));
	getButtonPanel().add(Box.createRigidArea(vstrut6));
	getButtonPanel().add(approveButton);
	getButtonPanel().add(Box.createRigidArea(vstrut4));

	cancelButton = new JButton(cancelButtonText) {
	    public Dimension getMaximumSize() {
		return approveButton.getPreferredSize().width > cancelButton.getPreferredSize().width ?
		       approveButton.getPreferredSize() : cancelButton.getPreferredSize();
	    }
	}; 
	cancelButton.setMargin(buttonMargin);
	cancelButton.setToolTipText(cancelButtonToolTipText);
	cancelButton.addActionListener(getCancelSelectionAction());
	getButtonPanel().add(cancelButton);

	if(fc.getControlButtonsAreShown()) {
	    addControlButtons();
	}
    
protected voidinstallListeners(javax.swing.JFileChooser fc)

	super.installListeners(fc);
        ActionMap actionMap = getActionMap();
        SwingUtilities.replaceUIActionMap(fc, actionMap);
    
protected voidinstallStrings(javax.swing.JFileChooser fc)

	super.installStrings(fc);

        Locale l = fc.getLocale();

	lookInLabelMnemonic = UIManager.getInt("FileChooser.lookInLabelMnemonic"); 
	lookInLabelText = UIManager.getString("FileChooser.lookInLabelText",l);
	saveInLabelText = UIManager.getString("FileChooser.saveInLabelText",l);
	
	fileNameLabelMnemonic = UIManager.getInt("FileChooser.fileNameLabelMnemonic");  
	fileNameLabelText = UIManager.getString("FileChooser.fileNameLabelText",l); 
	
	filesOfTypeLabelMnemonic = UIManager.getInt("FileChooser.filesOfTypeLabelMnemonic");  
	filesOfTypeLabelText = UIManager.getString("FileChooser.filesOfTypeLabelText",l); 
	
	upFolderToolTipText =  UIManager.getString("FileChooser.upFolderToolTipText",l);
	upFolderAccessibleName = UIManager.getString("FileChooser.upFolderAccessibleName",l); 
	
	homeFolderToolTipText =  UIManager.getString("FileChooser.homeFolderToolTipText",l);
	homeFolderAccessibleName = UIManager.getString("FileChooser.homeFolderAccessibleName",l); 
	
	newFolderToolTipText = UIManager.getString("FileChooser.newFolderToolTipText",l);
	newFolderAccessibleName = UIManager.getString("FileChooser.newFolderAccessibleName",l); 
	
	listViewButtonToolTipText = UIManager.getString("FileChooser.listViewButtonToolTipText",l); 
	listViewButtonAccessibleName = UIManager.getString("FileChooser.listViewButtonAccessibleName",l); 
	
	detailsViewButtonToolTipText = UIManager.getString("FileChooser.detailsViewButtonToolTipText",l); 
	detailsViewButtonAccessibleName = UIManager.getString("FileChooser.detailsViewButtonAccessibleName",l); 
    
public voidinstallUI(javax.swing.JComponent c)

	super.installUI(c);
    
protected voidremoveControlButtons()

	getBottomPanel().remove(getButtonPanel());
    
public voidrescanCurrentDirectory(javax.swing.JFileChooser fc)

	filePane.rescanCurrentDirectory();
    
public voidsetDirectoryName(java.lang.String dirname)

	// PENDING(jeff) - set the name in the directory combobox
    
protected voidsetDirectorySelected(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.

param
directorySelected if a directory is currently selected.
since
1.4

	super.setDirectorySelected(directorySelected);
	JFileChooser chooser = getFileChooser();
	if(directorySelected) {
	    approveButton.setText(directoryOpenButtonText);
	    approveButton.setToolTipText(directoryOpenButtonToolTipText);
	    approveButton.setMnemonic(directoryOpenButtonMnemonic);
	} else {
	    approveButton.setText(getApproveButtonText(chooser));
	    approveButton.setToolTipText(getApproveButtonToolTipText(chooser));
	    approveButton.setMnemonic(getApproveButtonMnemonic(chooser));
	}
    
public voidsetFileName(java.lang.String filename)

	if(filenameTextField != null) {
	    filenameTextField.setText(filename);
	}
    
public voiduninstallComponents(javax.swing.JFileChooser fc)

	fc.removeAll();
    
public voiduninstallUI(javax.swing.JComponent c)

	// Remove listeners
	c.removePropertyChangeListener(filterComboBoxModel);
	c.removePropertyChangeListener(filePane);
	if (placesBar != null) {
	    c.removePropertyChangeListener(placesBar);
	}
	cancelButton.removeActionListener(getCancelSelectionAction());
	approveButton.removeActionListener(getApproveSelectionAction());
	filenameTextField.removeActionListener(getApproveSelectionAction());

	if (filePane != null) {
	    filePane.uninstallUI();
	    filePane = null;
	}

	super.uninstallUI(c);
    
private voidupdateUseShellFolder()

	// Decide whether to use the ShellFolder class to populate shortcut
	// panel and combobox.
	JFileChooser fc = getFileChooser();
	Boolean prop =
	    (Boolean)fc.getClientProperty("FileChooser.useShellFolder");
	if (prop != null) {
	    useShellFolder = prop.booleanValue();
	} else {
	    // See if FileSystemView.getRoots() returns the desktop folder,
	    // i.e. the normal Windows hierarchy.
	    useShellFolder = false;
	    File[] roots = fc.getFileSystemView().getRoots();
	    if (roots != null && roots.length == 1) {
		File[] cbFolders = (File[])ShellFolder.get("fileChooserComboBoxFolders");
		if (cbFolders != null && cbFolders.length > 0 && roots[0] == cbFolders[0]) {
		    useShellFolder = true;
		}
	    }
	}
	if (OS_VERSION.compareTo("4.9") >= 0) {	// Windows Me/2000 and later (4.90/5.0)
	    if (useShellFolder) {
		if (placesBar == null && !UIManager.getBoolean("FileChooser.noPlacesBar")) {
		    placesBar = new WindowsPlacesBar(fc, XPStyle.getXP() != null);
		    fc.add(placesBar, BorderLayout.BEFORE_LINE_BEGINS);
		    fc.addPropertyChangeListener(placesBar);
		}
	    } else {
		if (placesBar != null) {
		    fc.remove(placesBar);
		    fc.removePropertyChangeListener(placesBar);
		    placesBar = null;
		}
	    }
	}
    
public voidvalueChanged(javax.swing.event.ListSelectionEvent e)

	JFileChooser fc = getFileChooser();
	File f = fc.getSelectedFile();
	if (!e.getValueIsAdjusting() && f != null && !getFileChooser().isTraversable(f)) {
	    setFileName(fileNameString(f));
	}