public class JFileChooser extends JComponent implements Accessible
JFileChooser提供用户选择一个文件的一个简单的机制。有关使用
JFileChooser信息看,
How to Use File Choosers,java教程中的一部分。
下面的代码将弹出一个文件选择为用户的主目录,只看到.jpg和.gif图像:
新jfilechooser() JFileChooser选择器=;filenameextensionfilter过滤器=新filenameextensionfilter(“JPG和GIF图像”、“JPG”、“GIF”);选择setfilefilter(过滤器);国际returnval =选择器。showMessageDialog(母);如果(returnval = =文件对话框。approve_option){系统。出来。println(“你选择打开此文件:“+选择器。getselectedfile() getname());}
警告: Swing是线程不安全的。更多信息见Swing's Threading Policy。
| Modifier and Type | Class and Description |
|---|---|
protected class |
JFileChooser.AccessibleJFileChooser
这个类实现了对
JFileChooser类可访问性支持。
|
JComponent.AccessibleJComponentContainer.AccessibleAWTContainerComponent.AccessibleAWTComponent, Component.BaselineResizeBehavior, Component.BltBufferStrategy, Component.FlipBufferStrategylistenerList, TOOL_TIP_TEXT_KEY, ui, UNDEFINED_CONDITION, WHEN_ANCESTOR_OF_FOCUSED_COMPONENT, WHEN_FOCUSED, WHEN_IN_FOCUSED_WINDOWBOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENTABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH| Constructor and Description |
|---|
JFileChooser()
构建了一个
JFileChooser指向用户的默认目录。
|
JFileChooser(File currentDirectory)
构建了一个
JFileChooser使用给定的
File作为路径。
|
JFileChooser(File currentDirectory, FileSystemView fsv)
使用给定的当前目录和
FileSystemView构建
JFileChooser。
|
JFileChooser(FileSystemView fsv)
使用给定的
FileSystemView构建
JFileChooser。
|
JFileChooser(String currentDirectoryPath)
使用给定的路径构建
JFileChooser。
|
JFileChooser(String currentDirectoryPath, FileSystemView fsv)
使用给定的当前目录路径和
FileSystemView构建
JFileChooser。
|
| Modifier and Type | Method and Description |
|---|---|
boolean |
accept(File f)
如果要显示文件,则返回真。
|
void |
addActionListener(ActionListener l)
增加了一个
ActionListener的文件选择器。
|
void |
addChoosableFileFilter(FileFilter filter)
用户可选择的文件筛选器列表添加一个过滤器。
|
void |
approveSelection()
当用户点击“批准”按钮(默认为“打开”或“保存”)时调用用户界面。
|
void |
cancelSelection()
当用户选择取消按钮时,由用户界面调用。
|
void |
changeToParentDirectory()
更改要设置为当前目录的父目录的目录。
|
protected JDialog |
createDialog(Component parent)
创建并返回一个新的
JDialog包装
this围绕在
parent的框架
parent。
|
void |
ensureFileIsVisible(File f)
确保指定的文件是可见的,而不是隐藏。
|
protected void |
fireActionPerformed(String command)
通知所有的听众,关于这一事件的类型通知已注册的兴趣。
|
FileFilter |
getAcceptAllFileFilter()
返回
AcceptAll文件过滤。
|
AccessibleContext |
getAccessibleContext()
获取与此相关的accessiblecontext JFileChooser。
|
JComponent |
getAccessory()
返回辅助组件。
|
ActionListener[] |
getActionListeners()
返回所有的监听行动在这个文件选择器注册一个数组。
|
int |
getApproveButtonMnemonic()
返回通过按钮的记忆。
|
String |
getApproveButtonText()
返回用于在
FileChooserUI的
ApproveButton文本。
|
String |
getApproveButtonToolTipText()
返回用于
ApproveButton工具提示文本。
|
FileFilter[] |
getChoosableFileFilters()
获取用户可选的文件筛选器列表。
|
boolean |
getControlButtonsAreShown()
返回的
controlButtonsAreShown属性的值。
|
File |
getCurrentDirectory()
返回当前目录。
|
String |
getDescription(File f)
返回文件描述。
|
String |
getDialogTitle()
获取字符串,在
JFileChooser的标题栏。
|
int |
getDialogType()
返回此对话框的类型。
|
boolean |
getDragEnabled()
得到的
dragEnabled属性的值。
|
FileFilter |
getFileFilter()
返回当前选定的文件筛选器。
|
int |
getFileSelectionMode()
返回当前文件选择模式。
|
FileSystemView |
getFileSystemView()
返回文件系统视图。
|
FileView |
getFileView()
返回当前文件视图。
|
Icon |
getIcon(File f)
返回此文件或文件类型的图标,取决于系统。
|
String |
getName(File f)
返回文件名。
|
File |
getSelectedFile()
返回选定的文件。
|
File[] |
getSelectedFiles()
返回一个列表中选定的文件,如果文件选择器设置为允许多重选择。
|
String |
getTypeDescription(File f)
返回文件类型。
|
FileChooserUI |
getUI()
获取实现该组件的“L”的用户界面对象。
|
String |
getUIClassID()
返回一个字符串,指定呈现此组件的“L”和“F”类的名称。
|
boolean |
isAcceptAllFileFilterUsed()
是否使用
AcceptAll FileFilter。
|
boolean |
isDirectorySelectionEnabled()
方便调用,确定基于当前文件选择模式下的目录是否可选择。
|
boolean |
isFileHidingEnabled()
如果隐藏文件不在文件选择器显示返回true;否则,返回false。
|
boolean |
isFileSelectionEnabled()
方便调用,确定基于当前文件选择模式是否可选择文件。
|
boolean |
isMultiSelectionEnabled()
如果选择了多个文件,则返回真。
|
boolean |
isTraversable(File f)
如果访问了文件(目录),则返回真。
|
protected String |
paramString()
返回该
JFileChooser字符串表示形式。
|
void |
removeActionListener(ActionListener l)
删除从文件选择一个
ActionListener。
|
boolean |
removeChoosableFileFilter(FileFilter f)
删除从用户可选的文件筛选器列表过滤。
|
void |
rescanCurrentDirectory()
告诉用户重新扫描文件列出当前目录。
|
void |
resetChoosableFileFilters()
复位可选文件筛选器列表的开始状态。
|
void |
setAcceptAllFileFilterUsed(boolean b)
确定
AcceptAll FileFilter作为可选择的筛选器列表供选择。
|
void |
setAccessory(JComponent newAccessory)
设置附件组件。
|
void |
setApproveButtonMnemonic(char mnemonic)
设置按钮的助记符批准使用角色。
|
void |
setApproveButtonMnemonic(int mnemonic)
设置按钮的助记符批准使用数字键码。
|
void |
setApproveButtonText(String approveButtonText)
设置用于在
FileChooserUI的
ApproveButton文本。
|
void |
setApproveButtonToolTipText(String toolTipText)
集应用在
ApproveButton工具提示文本。
|
void |
setControlButtonsAreShown(boolean b)
设置属性,指示批准和取消按钮中显示的文件选择器。
|
void |
setCurrentDirectory(File dir)
设置当前目录。
|
void |
setDialogTitle(String dialogTitle)
设置字符串,在
JFileChooser窗口的标题栏。
|
void |
setDialogType(int dialogType)
设置此对话框的类型。
|
void |
setDragEnabled(boolean b)
集
dragEnabled财产,必须
true启用自动处理(拖动拖放第一部分)对该组件。
|
void |
setFileFilter(FileFilter filter)
设置当前文件筛选器。
|
void |
setFileHidingEnabled(boolean b)
设置文件隐藏或关闭。
|
void |
setFileSelectionMode(int mode)
集
JFileChooser允许用户只需选择文件,选择目录,或选择文件和目录。
|
void |
setFileSystemView(FileSystemView fsv)
设置文件系统的观点,
JFileChooser用于访问和创建文件系统资源,如发现软驱和列表的根驱动器。
|
void |
setFileView(FileView fileView)
设置用于检索用户界面信息的文件视图,如表示文件的图标或文件的类型说明。
|
void |
setMultiSelectionEnabled(boolean b)
设置允许多个文件选择文件选择器。
|
void |
setSelectedFile(File file)
设置选定的文件。
|
void |
setSelectedFiles(File[] selectedFiles)
设置选定的文件列表如果文件选择器设置为允许多重选择。
|
protected void |
setup(FileSystemView view)
执行常见的构造函数初始化和设置。
|
int |
showDialog(Component parent, String approveButtonText)
POPs具有自定义审批按钮自定义文件选择对话框。
|
int |
showOpenDialog(Component parent)
弹出“打开文件”文件选择对话框。
|
int |
showSaveDialog(Component parent)
弹出一个“保存文件”文件选择对话框。
|
void |
updateUI()
重置UI属性从目前看价值和感觉。
|
addAncestorListener, addNotify, addVetoableChangeListener, computeVisibleRect, contains, createToolTip, disable, enable, firePropertyChange, firePropertyChange, firePropertyChange, fireVetoableChange, getActionForKeyStroke, getActionMap, getAlignmentX, getAlignmentY, getAncestorListeners, getAutoscrolls, getBaseline, getBaselineResizeBehavior, getBorder, getBounds, getClientProperty, getComponentGraphics, getComponentPopupMenu, getConditionForKeyStroke, getDebugGraphicsOptions, getDefaultLocale, getFontMetrics, getGraphics, getHeight, getInheritsPopupMenu, getInputMap, getInputMap, getInputVerifier, getInsets, getInsets, getListeners, getLocation, getMaximumSize, getMinimumSize, getNextFocusableComponent, getPopupLocation, getPreferredSize, getRegisteredKeyStrokes, getRootPane, getSize, getToolTipLocation, getToolTipText, getToolTipText, getTopLevelAncestor, getTransferHandler, getVerifyInputWhenFocusTarget, getVetoableChangeListeners, getVisibleRect, getWidth, getX, getY, grabFocus, hide, isDoubleBuffered, isLightweightComponent, isManagingFocus, isOpaque, isOptimizedDrawingEnabled, isPaintingForPrint, isPaintingOrigin, isPaintingTile, isRequestFocusEnabled, isValidateRoot, paint, paintBorder, paintChildren, paintComponent, paintImmediately, paintImmediately, print, printAll, printBorder, printChildren, printComponent, processComponentKeyEvent, processKeyBinding, processKeyEvent, processMouseEvent, processMouseMotionEvent, putClientProperty, registerKeyboardAction, registerKeyboardAction, removeAncestorListener, removeNotify, removeVetoableChangeListener, repaint, repaint, requestDefaultFocus, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, resetKeyboardActions, reshape, revalidate, scrollRectToVisible, setActionMap, setAlignmentX, setAlignmentY, setAutoscrolls, setBackground, setBorder, setComponentPopupMenu, setDebugGraphicsOptions, setDefaultLocale, setDoubleBuffered, setEnabled, setFocusTraversalKeys, setFont, setForeground, setInheritsPopupMenu, setInputMap, setInputVerifier, setMaximumSize, setMinimumSize, setNextFocusableComponent, setOpaque, setPreferredSize, setRequestFocusEnabled, setToolTipText, setTransferHandler, setUI, setVerifyInputWhenFocusTarget, setVisible, unregisterKeyboardAction, updateadd, add, add, add, add, addContainerListener, addImpl, addPropertyChangeListener, addPropertyChangeListener, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getComponentZOrder, getContainerListeners, getFocusTraversalKeys, getFocusTraversalPolicy, getLayout, getMousePosition, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusCycleRoot, isFocusTraversalPolicyProvider, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paintComponents, preferredSize, printComponents, processContainerEvent, processEvent, remove, remove, removeAll, removeContainerListener, setComponentZOrder, setFocusCycleRoot, setFocusTraversalPolicy, setFocusTraversalPolicyProvider, setLayout, transferFocusDownCycle, validate, validateTreeaction, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addMouseWheelListener, bounds, checkImage, checkImage, coalesceEvents, contains, createImage, createImage, createVolatileImage, createVolatileImage, disableEvents, dispatchEvent, enable, enableEvents, enableInputMethods, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getBackground, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusCycleRootAncestor, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getForeground, getGraphicsConfiguration, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputContext, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocale, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMousePosition, getMouseWheelListeners, getName, getParent, getPeer, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getToolkit, getTreeLock, gotFocus, handleEvent, hasFocus, imageUpdate, inside, isBackgroundSet, isCursorSet, isDisplayable, isEnabled, isFocusable, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, isMaximumSizeSet, isMinimumSizeSet, isPreferredSizeSet, isShowing, isValid, isVisible, keyDown, keyUp, list, list, list, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, postEvent, prepareImage, prepareImage, processComponentEvent, processFocusEvent, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, processMouseWheelEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, resize, resize, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setFocusable, setFocusTraversalKeysEnabled, setIgnoreRepaint, setLocale, setLocation, setLocation, setName, setSize, setSize, show, show, size, toString, transferFocus, transferFocusBackward, transferFocusUpCyclepublic static final int OPEN_DIALOG
JFileChooser支持“打开”文件操作。
public static final int SAVE_DIALOG
JFileChooser支持“保存”文件的操作。
public static final int CUSTOM_DIALOG
JFileChooser支持开发商指定的文件操作。
public static final int CANCEL_OPTION
public static final int APPROVE_OPTION
public static final int ERROR_OPTION
public static final int FILES_ONLY
public static final int DIRECTORIES_ONLY
public static final int FILES_AND_DIRECTORIES
public static final String CANCEL_SELECTION
public static final String APPROVE_SELECTION
public static final String APPROVE_BUTTON_TEXT_CHANGED_PROPERTY
public static final String APPROVE_BUTTON_TOOL_TIP_TEXT_CHANGED_PROPERTY
public static final String APPROVE_BUTTON_MNEMONIC_CHANGED_PROPERTY
public static final String CONTROL_BUTTONS_ARE_SHOWN_CHANGED_PROPERTY
public static final String DIRECTORY_CHANGED_PROPERTY
public static final String SELECTED_FILE_CHANGED_PROPERTY
public static final String SELECTED_FILES_CHANGED_PROPERTY
public static final String MULTI_SELECTION_ENABLED_CHANGED_PROPERTY
public static final String FILE_SYSTEM_VIEW_CHANGED_PROPERTY
public static final String FILE_VIEW_CHANGED_PROPERTY
public static final String FILE_HIDING_CHANGED_PROPERTY
public static final String FILE_FILTER_CHANGED_PROPERTY
public static final String FILE_SELECTION_MODE_CHANGED_PROPERTY
public static final String ACCESSORY_CHANGED_PROPERTY
public static final String ACCEPT_ALL_FILE_FILTER_USED_CHANGED_PROPERTY
public static final String DIALOG_TITLE_CHANGED_PROPERTY
public static final String DIALOG_TYPE_CHANGED_PROPERTY
public static final String CHOOSABLE_FILE_FILTER_CHANGED_PROPERTY
protected AccessibleContext accessibleContext
public JFileChooser()
JFileChooser指向用户的默认目录。此默认取决于操作系统。它通常是在Windows的“我的文档”文件夹中,和用户的家目录在UNIX。
public JFileChooser(String currentDirectoryPath)
JFileChooser。通过在一个
null字符串使文件选择器指向用户的默认目录。此默认取决于操作系统。它通常是在Windows的“我的文档”文件夹中,和用户的家目录在UNIX。
currentDirectoryPath -
String给一个文件的路径或目录
public JFileChooser(File currentDirectory)
File为路径,构建一个
JFileChooser。通过在一个
null文件使文件选择器指向用户的默认目录。此默认取决于操作系统。它通常是在Windows的“我的文档”文件夹中,和用户的家目录在UNIX。
currentDirectory -
File对象指定文件或目录的路径
public JFileChooser(FileSystemView fsv)
FileSystemView构建
JFileChooser。
public JFileChooser(File currentDirectory, FileSystemView fsv)
FileSystemView构建
JFileChooser。
public JFileChooser(String currentDirectoryPath, FileSystemView fsv)
FileSystemView构建
JFileChooser。
protected void setup(FileSystemView view)
public void setDragEnabled(boolean b)
dragEnabled财产,必须
true启用自动处理(拖动拖放第一部分)对该组件。的
transferHandler属性必须设置为非为拖去做任何
null价值。该
dragEnabled属性的默认值是
false。
当启用自动拖动处理时,当用户按下鼠标按钮超过一个项目时,大多数的外观和感觉开始拖放操作,然后移动鼠标几像素。将此属性设置为true因此可以有选择的行为有潜移默化的影响。
一些看起来和感觉可能不支持自动拖放,他们会忽略这个属性。你可以工作在这样的外观和感觉通过修改组件直接调用一个方法的exportAsDrag TransferHandler。
b -设置
dragEnabled属性的值
HeadlessException -如果
b是
true和
GraphicsEnvironment.isHeadless()返回
true
GraphicsEnvironment.isHeadless(),
getDragEnabled(),
JComponent.setTransferHandler(javax.swing.TransferHandler),
TransferHandler
public boolean getDragEnabled()
dragEnabled属性的值。
dragEnabled属性的值
setDragEnabled(boolean)
public File getSelectedFile()
setSelectedFile或程序员的用户动作,如任一输入文件名为UI或选择从UI列表文件。
setSelectedFile(java.io.File)
public void setSelectedFile(File file)
file -选定的文件
getSelectedFile()
public File[] getSelectedFiles()
public void setSelectedFiles(File[] selectedFiles)
public File getCurrentDirectory()
setCurrentDirectory(java.io.File)
public void setCurrentDirectory(File dir)
null集文件选择器指向用户的默认目录。此默认取决于操作系统。它通常是在Windows的“我的文档”文件夹中,和用户的家目录在UNIX。如果文件通过在
currentDirectory不是一个目录,该文件的父将作为当前目录。如果家长不可,那么它会走的父树直到找到一个遍历目录,或点击该文件系统的根。
dir -指当前目录
getCurrentDirectory()
public void changeToParentDirectory()
getCurrentDirectory()
public void rescanCurrentDirectory()
public void ensureFileIsVisible(File f)
f -一个文件对象
public int showOpenDialog(Component parent) throws HeadlessException
parent -对话框的父组件,可以
null;看到
showDialog详情
HeadlessException -如果graphicsenvironment isheadless()返回true。
GraphicsEnvironment.isHeadless(),
showDialog(java.awt.Component, java.lang.String)
public int showSaveDialog(Component parent) throws HeadlessException
parent -对话框的父组件,可以
null;看到
showDialog详情
HeadlessException -如果graphicsenvironment isheadless()返回true。
GraphicsEnvironment.isHeadless(),
showDialog(java.awt.Component, java.lang.String)
public int showDialog(Component parent, String approveButtonText) throws HeadlessException
然后在fileChooser. ShowDialog(parentframe,“运行应用程序”);另外,下面的代码做了同样的事:
JFileChooser选择器=新文件对话框(空);选择器。setapprovebuttontext(“运行应用程序”);选择器。ShowDialog(parentframe,null);
的parent参数决定了两件事:架上,打开对话框取决于组件的外观和感觉应该考虑放置对话框时,其位置。如果父母是一个Frame对象(如JFrame)然后对话框取决于框架和外观和感觉的对话框位置相对于框架(例如,集中在框架)。如果父是一个组件,则对话框取决于包含该组件的框架,并将其定位到组件(例如,以组件为中心)。如果家长null,然后对话框取决于不可见的窗口,它是放置在一个外观和感觉有关的位置如屏幕的中心。
parent -对话框的父组件;可以
null
approveButtonText的
ApproveButton文本
HeadlessException -如果graphicsenvironment isheadless()返回true。
GraphicsEnvironment.isHeadless()
protected JDialog createDialog(Component parent) throws HeadlessException
JDialog包装
this围绕在
parent的框架
parent。该方法可以被重写的进一步操作的对话框,禁用缩放、设置的位置,例如:
类myfilechooser延伸JFileChooser {保护createdialog JDialog(成分母)抛出headlessexception {JDialog对话框=超级createdialog(母);对话框。setlocation(300,200);对话框。setresizable(假);返回对话框;}}等
parent -对话框的父组件;可以
null
JDialog包含此实例
HeadlessException -如果graphicsenvironment isheadless()返回true。
GraphicsEnvironment.isHeadless()
public boolean getControlButtonsAreShown()
controlButtonsAreShown属性的值。
controlButtonsAreShown属性的值
setControlButtonsAreShown(boolean)
public void setControlButtonsAreShown(boolean b)
true。看和感觉,总是显示这些按钮将忽略此属性的值。这种方法的火属性更改事件,利用
CONTROL_BUTTONS_ARE_SHOWN_CHANGED_PROPERTY字符串值作为属性的名称。
b -
false如果控制按钮不应该显示;否则,
true
getControlButtonsAreShown(),
CONTROL_BUTTONS_ARE_SHOWN_CHANGED_PROPERTY
public int getDialogType()
JFileChooser.OPEN_DIALOG。
setDialogType(int)
public void setDialogType(int dialogType)
OPEN_DIALOG。同样,使用
SAVE_DIALOG让用户选择一个文件保存。使用
CUSTOM_DIALOG当你想要使用的文件选择器中除了“打开”或“保存”。例如,你可能想把一个文件选择器允许用户选择执行文件。注意,你通常不需要设置
JFileChooser使用
CUSTOM_DIALOG因为调用
setApproveButtonText为你做的。默认的对话框类型
JFileChooser.OPEN_DIALOG。
dialogType -将显示对话框类型:
IllegalArgumentException -如果
dialogType是不合法的
getDialogType(),
setApproveButtonText(java.lang.String)
public void setDialogTitle(String dialogTitle)
JFileChooser窗口的标题栏。
dialogTitle -标题栏的新
String
getDialogTitle()
public String getDialogTitle()
JFileChooser的标题栏。
public void setApproveButtonToolTipText(String toolTipText)
ApproveButton工具提示文本。如果
null,UI对象将确定按钮的文本。
toolTipText -批准”按钮的工具提示文本
setApproveButtonText(java.lang.String),
setDialogType(int),
showDialog(java.awt.Component, java.lang.String)
public String getApproveButtonToolTipText()
ApproveButton工具提示文本。如果
null,UI对象将确定按钮的文本。
setApproveButtonText(java.lang.String),
setDialogType(int),
showDialog(java.awt.Component, java.lang.String)
public int getApproveButtonMnemonic()
setApproveButtonMnemonic(int)
public void setApproveButtonMnemonic(int mnemonic)
mnemonic -记忆的关键一个整型值
getApproveButtonMnemonic()
public void setApproveButtonMnemonic(char mnemonic)
mnemonic -记忆的关键字符的值
getApproveButtonMnemonic()
public void setApproveButtonText(String approveButtonText)
FileChooserUI在
ApproveButton用文字。
approveButtonText用于
ApproveButton文本
getApproveButtonText(),
setDialogType(int),
showDialog(java.awt.Component, java.lang.String)
public String getApproveButtonText()
FileChooserUI的
ApproveButton文本。如果
null,UI对象将确定按钮的文本。通常情况下,这将是“打开”或“保存”。
ApproveButton文本
setApproveButtonText(java.lang.String),
setDialogType(int),
showDialog(java.awt.Component, java.lang.String)
public FileFilter[] getChoosableFileFilters()
FileFilter阵列
addChoosableFileFilter(javax.swing.filechooser.FileFilter),
removeChoosableFileFilter(javax.swing.filechooser.FileFilter),
resetChoosableFileFilters()
public void addChoosableFileFilter(FileFilter filter)
setFileSelectionMode。
filter -
FileFilter添加到可选的文件筛选器列表
getChoosableFileFilters(),
removeChoosableFileFilter(javax.swing.filechooser.FileFilter),
resetChoosableFileFilters(),
setFileSelectionMode(int)
public boolean removeChoosableFileFilter(FileFilter f)
public void resetChoosableFileFilters()
AcceptAll文件过滤。
public FileFilter getAcceptAllFileFilter()
AcceptAll文件过滤。例如,在微软的窗口中,这将是所有的文件(**)。
public boolean isAcceptAllFileFilterUsed()
AcceptAll FileFilter。
AcceptAll FileFilter使用
setAcceptAllFileFilterUsed(boolean)
public void setAcceptAllFileFilterUsed(boolean b)
AcceptAll FileFilter作为可选择的筛选器列表供选择。如果是错的,这
AcceptAll文件过滤器是从可用的文件筛选器列表中删除。如果真的
AcceptAll文件过滤器将成为积极使用文件过滤。
public JComponent getAccessory()
setAccessory(javax.swing.JComponent)
public void setAccessory(JComponent newAccessory)
注意:如果有一个以前的配件,你应该注销任何听众,附件可能与文件选择器注册。
public void setFileSelectionMode(int mode)
JFileChooser,只要选择目录,或选择文件和目录。默认的是
JFilesChooser.FILES_ONLY。
mode -要显示的文件类型:
IllegalArgumentException -如果
mode是非法文件选择模式
getFileSelectionMode()
public int getFileSelectionMode()
JFilesChooser.FILES_ONLY。
setFileSelectionMode(int)
public boolean isFileSelectionEnabled()
public boolean isDirectorySelectionEnabled()
public void setMultiSelectionEnabled(boolean b)
b -如果可以选择多个文件
isMultiSelectionEnabled()
public boolean isMultiSelectionEnabled()
setMultiSelectionEnabled(boolean)
public boolean isFileHidingEnabled()
setFileHidingEnabled(boolean)
public void setFileHidingEnabled(boolean b)
FileView做。
b的布尔值,确定是否隐藏文件的打开
isFileHidingEnabled()
public void setFileFilter(FileFilter filter)
filter -新的当前文件过滤器的使用
getFileFilter()
public FileFilter getFileFilter()
public void setFileView(FileView fileView)
getFileView()
public FileView getFileView()
public String getName(File f)
f -
File
String
f
FileView.getName(java.io.File)
public String getDescription(File f)
f -
File
f文件描述
String
FileView.getDescription(java.io.File)
public String getTypeDescription(File f)
f -
File
f文件类型描述
String
FileView.getTypeDescription(java.io.File)
public Icon getIcon(File f)
f -
File
Icon,或文件类型
FileView.getIcon(java.io.File)
public boolean isTraversable(File f)
f -
File
FileView.isTraversable(java.io.File)
public boolean accept(File f)
f -
File
FileFilter.accept(java.io.File)
public void setFileSystemView(FileSystemView fsv)
JFileChooser用于访问和创建文件系统资源,如发现软驱和列表的根驱动器。
fsv -新的
FileSystemView
FileSystemView
public FileSystemView getFileSystemView()
FileSystemView对象
setFileSystemView(javax.swing.filechooser.FileSystemView)
public void approveSelection()
APPROVE_SELECTION。
APPROVE_SELECTION
public void cancelSelection()
CANCEL_SELECTION。
CANCEL_SELECTION
public void addActionListener(ActionListener l)
ActionListener的文件选择器。
l -监听器被添加
approveSelection(),
cancelSelection()
public void removeActionListener(ActionListener l)
ActionListener。
l -听者被删除
addActionListener(java.awt.event.ActionListener)
public ActionListener[] getActionListeners()
ActionListeners或空数组如果没有行动的听众正在注册
addActionListener(java.awt.event.ActionListener),
removeActionListener(java.awt.event.ActionListener)
protected void fireActionPerformed(String command)
command参数。
EventListenerList
public void updateUI()
updateUI 方法重写,继承类
JComponent
JComponent.updateUI()
public String getUIClassID()
getUIClassID 方法重写,继承类
JComponent
JComponent.getUIClassID(),
UIDefaults.getUI(javax.swing.JComponent)
public FileChooserUI getUI()
protected String paramString()
JFileChooser字符串表示形式。此方法仅用于调试目的,返回的字符串的内容和格式可能会在实现过程中有所不同。返回的字符串是空的但可能不
null。
paramString 方法重写,继承类
JComponent
JFileChooser字符串表示形式
public AccessibleContext getAccessibleContext()
getAccessibleContext 接口
Accessible
getAccessibleContext 方法重写,继承类
Component
Submit a bug or feature
For further API reference and developer documentation, see Java SE Documentation. That documentation contains more detailed, developer-targeted descriptions, with conceptual overviews, definitions of terms, workarounds, and working code examples.
Copyright © 1993, 2014, Oracle and/or its affiliates. All rights reserved.