⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 jfilechooser.java

📁 gcc的组建
💻 JAVA
📖 第 1 页 / 共 3 页
字号:
/* JFileChooser.java --   Copyright (C) 2002, 2004, 2005  Free Software Foundation, Inc.This file is part of GNU Classpath.GNU Classpath is free software; you can redistribute it and/or modifyit under the terms of the GNU General Public License as published bythe 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, butWITHOUT ANY WARRANTY; without even the implied warranty ofMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNUGeneral Public License for more details.You should have received a copy of the GNU General Public Licensealong with GNU Classpath; see the file COPYING.  If not, write to theFree Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA02110-1301 USA.Linking this library statically or dynamically with other modules ismaking a combined work based on this library.  Thus, the terms andconditions of the GNU General Public License cover the wholecombination.As a special exception, the copyright holders of this library give youpermission to link this library with independent modules to produce anexecutable, regardless of the license terms of these independentmodules, and to copy and distribute the resulting executable underterms of your choice, provided that you also meet, for each linkedindependent module, the terms and conditions of the license of thatmodule.  An independent module is a module which is not derived fromor based on this library.  If you modify this library, you may extendthis exception to your version of the library, but you are notobligated to do so.  If you do not wish to do so, delete thisexception statement from your version. */package javax.swing;import java.awt.Component;import java.awt.Frame;import java.awt.HeadlessException;import java.awt.event.ActionEvent;import java.awt.event.ActionListener;import java.beans.PropertyChangeEvent;import java.io.File;import java.util.ArrayList;import javax.accessibility.Accessible;import javax.accessibility.AccessibleContext;import javax.accessibility.AccessibleRole;import javax.swing.JDialog;import javax.swing.filechooser.FileFilter;import javax.swing.filechooser.FileSystemView;import javax.swing.filechooser.FileView;import javax.swing.plaf.FileChooserUI;/** * A component that provides the user a dialog box to browse through a * filesystem and choose one or more files or directories. * * A JFileChooser can be configured to filter the displayed file list * by adding a {@link FileFilter} instance using * {@link #addChoosableFileFilter(FileFilter)}. Additional components can * be embedded in the file chooser using {@link #setAccessory(JComponent)}. * The JFileChooser properties also provide mechanisms to customize the * behaviour of the file chooser. * * @author Kim Ho (kho@luxsci.net) */public class JFileChooser extends JComponent implements Accessible{  private static final long serialVersionUID = 3162921138695327837L;  /**    * A dialog type for selecting a file to open.    * @see #setDialogType(int)   */  public static final int OPEN_DIALOG = 0;  /**    * A dialog type for selecting a file to save.     * @see #setDialogType(int)   */  public static final int SAVE_DIALOG = 1;  /**    * A dialog type for some custom purpose.   * @see #setDialogType(int)   */  public static final int CUSTOM_DIALOG = 2;  /**    * A return value indicating the file chooser has been closed by cancelling.   *    * @see #showOpenDialog(Component)   * @see #showSaveDialog(Component)    */  public static final int CANCEL_OPTION = 1;  /**    * A return value indicating the file chooser has been closed by approving   * the selection.   * @see #showOpenDialog(Component)   * @see #showSaveDialog(Component)    */  public static final int APPROVE_OPTION = 0;  /**    * A return value indicating the file chooser has been closed by some error.   * @see #showOpenDialog(Component)   * @see #showSaveDialog(Component)    */  public static final int ERROR_OPTION = -1;  /**    * A selection mode constant indicating acceptance of files only.   * @see #setFileSelectionMode(int)   */  public static final int FILES_ONLY = 0;  /**    * A selection mode constant indicating acceptance of directories only.    * @see #setFileSelectionMode(int)   */  public static final int DIRECTORIES_ONLY = 1;  /**    * A selection mode constant indicating acceptance of files and directories.   * @see #setFileSelectionMode(int)   */  public static final int FILES_AND_DIRECTORIES = 2;  /**    * Action command string for cancelling the current selection.   * @see #cancelSelection()   */  public static final String CANCEL_SELECTION = "CancelSelection";  /**    * Action command string for approving the current selection.   * @see #cancelSelection()   */  public static final String APPROVE_SELECTION = "ApproveSelection";  /**   * The name of the property for the approve button text.   * @see #setApproveButtonText(String)    */  public static final String APPROVE_BUTTON_TEXT_CHANGED_PROPERTY =    "ApproveButtonTextChangedProperty";  /**   * The name of the property for the approve button tool tip text.   * @see #setApproveButtonToolTipText(String)   */  public static final String APPROVE_BUTTON_TOOL_TIP_TEXT_CHANGED_PROPERTY =    "ApproveButtonToolTipTextChangedProperty";  /**   * The name of the property for the approve button mnemonic.   * @see #setApproveButtonMnemonic(int)   */  public static final String APPROVE_BUTTON_MNEMONIC_CHANGED_PROPERTY =    "ApproveButtonMnemonicChangedProperty";  /**   * The name of the property for control button visibility.   * @see #setControlButtonsAreShown(boolean)   */  public static final String CONTROL_BUTTONS_ARE_SHOWN_CHANGED_PROPERTY =    "ControlButtonsAreShownChangedProperty";  /**   * The name of the property for the current directory.   * @see #setCurrentDirectory(File)     */  public static final String DIRECTORY_CHANGED_PROPERTY = "directoryChanged";  /**   * The name of the property for the selected file.   * @see #setSelectedFile(File)   */  public static final String SELECTED_FILE_CHANGED_PROPERTY =    "SelectedFileChangedProperty";  /**   * The name of the property for the selected files.   * @see #setSelectedFiles(File[])   */  public static final String SELECTED_FILES_CHANGED_PROPERTY =    "SelectedFilesChangedProperty";  /**    * The name of the property for multi-selection.   * @see #setMultiSelectionEnabled(boolean)    */  public static final String MULTI_SELECTION_ENABLED_CHANGED_PROPERTY =    "MultiSelectionEnabledChangedProperty";  /**   * The name of the 'file system view' property.   * @see #setFileSystemView(FileSystemView)    */  public static final String FILE_SYSTEM_VIEW_CHANGED_PROPERTY =    "FileSystemViewChanged";  /**   * The name of the 'file view' property.   * @see #setFileView(FileView)    */  public static final String FILE_VIEW_CHANGED_PROPERTY = "fileViewChanged";  /**   * The name of the 'file hiding enabled' property.   * @see #setFileHidingEnabled(boolean)   */  public static final String FILE_HIDING_CHANGED_PROPERTY =    "FileHidingChanged";  /**   * The name of the 'file filter' property.   * @see #setFileFilter(FileFilter)   */  public static final String FILE_FILTER_CHANGED_PROPERTY =    "fileFilterChanged";  /**   * The name of the 'file selection mode' property.   * @see #setFileSelectionMode(int)   */  public static final String FILE_SELECTION_MODE_CHANGED_PROPERTY =    "fileSelectionChanged";  /**   * The name of the 'accessory' property.   * @see #setAccessory(JComponent)   */  public static final String ACCESSORY_CHANGED_PROPERTY =    "AccessoryChangedProperty";  /**   * The name of the 'accept all file filter used' property.   * @see #setAcceptAllFileFilterUsed(boolean)   */  public static final String ACCEPT_ALL_FILE_FILTER_USED_CHANGED_PROPERTY =    "acceptAllFileFilterUsedChanged";  /**   * The name of the 'dialog title' property.   * @see #setDialogTitle(String)   */  public static final String DIALOG_TITLE_CHANGED_PROPERTY =    "DialogTitleChangedProperty";  /**   * The name of the 'dialog type' property.   * @see #setDialogType(int)   */  public static final String DIALOG_TYPE_CHANGED_PROPERTY =    "DialogTypeChangedProperty";  /**   * The name of the 'choosable file filters' property.   * @see #addChoosableFileFilter(FileFilter)   */  public static final String CHOOSABLE_FILE_FILTER_CHANGED_PROPERTY =    "ChoosableFileFilterChangedProperty";  /**    * The accessible context.    * @see #getAccessibleContext()   */  protected AccessibleContext accessibleContext;  /**    * The file system view.   * @see #setFileSystemView(FileSystemView)   */  private FileSystemView fsv;  /**   * The accessory component.   * @see #setAccessory(JComponent)   */  private JComponent accessory;  /**   * The approve button mnemonic.   * @see #setApproveButtonMnemonic(int)   */  private int approveButtonMnemonic = 0;  /**   * The approve button text.   * @see #setApproveButtonText(String)   */  private String approveButtonText;  /**   * The approve button tool tip text.   * @see #setApproveButtonToolTipText(String)   */  private String approveButtonToolTipText;  /**   * The choosable file filters.   * @see #addChoosableFileFilter(FileFilter)   */  private ArrayList choosableFilters = new ArrayList();  /**   * A flag controlling whether the accept all file filter is used.   * @see #setAcceptAllFileFilterUsed(boolean)   */  private boolean isAcceptAll = true;  /**   * The dialog title.   * @see #setDialogTitle(String)   */  private String dialogTitle;  /**   * The dialog type.   * @see #setDialogType(int)   */  private int dialogType = OPEN_DIALOG;  /**   * The return value for the dialog.   * @see #showOpenDialog(Component)   * @see #showSaveDialog(Component)   */  private int retval = ERROR_OPTION;  /**   * A flag indicating whether the file chooser allows multiple selection.   * @see #isMultiSelectionEnabled()   */  private boolean multiSelection = false;  /**   * A flag indicating whether file hiding is enabled.   * @see #isFileHidingEnabled()   */  private boolean fileHiding = true;  /**   * The file selection mode.   * @see #setFileSelectionMode(int)    */  private int fileSelectionMode = FILES_AND_DIRECTORIES;  /**    * The file view.   * @see #setFileView(FileView)   */  private FileView fv = null;  /**    * A flag controlling whether or not the control buttons are visible.    * @see #setControlButtonsAreShown(boolean)    */  private boolean controlButtonsShown = true;  /**    * The current directory.    * @see #setCurrentDirectory(File)   */  private File currentDir = null;  /**    * The current file filter.   * @see #setFileFilter(FileFilter)   */  private FileFilter currentFilter = null;  /**    * An array of selected files.   * @see #setSelectedFiles(File[])    */  private File[] selectedFiles;  /**    * The selected file.    * @see #setSelectedFile(File)   */  private File selectedFile;  /**   * Creates a new <code>JFileChooser</code> object.   */  public JFileChooser()  {    setup(null);    setCurrentDirectory(null);  }  /**   * Creates a new <code>JFileChooser</code> object.   *   * @param currentDirectoryPath the directory that should initially be   *        shown in the filechooser (if <code>null</code>, the user's home    *        directory is used).   */  public JFileChooser(String currentDirectoryPath)  {    setup(null);    setCurrentDirectory(fsv.createFileObject(currentDirectoryPath));  }  /**   * Creates a new <code>JFileChooser</code> object with the specified    * directory and {@link FileSystemView}.   *   * @param currentDirectoryPath  the directory that should initially be   *        shown in the filechooser (if <code>null</code>, the user's home    *        directory is used).   * @param fsv  the file system view (if <code>null</code>, the default file   *             system view is used).   */  public JFileChooser(String currentDirectoryPath, FileSystemView fsv)  {    setup(fsv);    setCurrentDirectory(fsv.createFileObject(currentDirectoryPath));  }  /**   * Creates a new <code>JFileChooser</code> object.   *   * @param currentDirectory  the directory that should initially be   *        shown in the filechooser (if <code>null</code>, the user's home    *        directory is used).   */  public JFileChooser(File currentDirectory)  {    setup(null);    setCurrentDirectory(currentDirectory);  }  /**   * Creates a new <code>JFileChooser</code> object.   *   * @param fsv  the file system view (if <code>null</code>, the default file   *             system view is used).   */  public JFileChooser(FileSystemView fsv)  {    setup(fsv);    setCurrentDirectory(null);  }  /**   * Creates a new <code>JFileChooser</code> object.   *   * @param currentDirectory  the directory that should initially be   *        shown in the filechooser (if <code>null</code>, the user's home    *        directory is used).   * @param fsv  the file system view (if <code>null</code>, the default file   *             system view is used).   */  public JFileChooser(File currentDirectory, FileSystemView fsv)  {    setup(fsv);    setCurrentDirectory(currentDirectory);  }  /**   * Sets up the file chooser.  This method is called by all the constructors.   *   * @param view  the file system view (if <code>null</code>, the default file   *              system view is used).   *    * @see FileSystemView#getFileSystemView()   */  protected void setup(FileSystemView view)  {    if (view == null)      view = FileSystemView.getFileSystemView();    setFileSystemView(view);    updateUI();  }  /**   * DOCUMENT ME!   *   * @param b DOCUMENT ME!   */  public void setDragEnabled(boolean b)  {    // FIXME: Implement  }  /**   * DOCUMENT ME!   *   * @return DOCUMENT ME!   */  public boolean getDragEnabled()  {    // FIXME: Implement    return false;  }  /**   * Returns the selected file, if there is one.   *   * @return The selected file (possibly <code>null</code>).

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -