FileDialog class displays a dialog window
from which the user can select a file.
Since it is a modal dialog, when the application calls
its show method to display the dialog,
it blocks the rest of the application until the user has
chosen a file.
Window.show(),
Serialized FormDialog.AccessibleAWTDialog, Dialog.ModalExclusionType, Dialog.ModalityTypeWindow.AccessibleAWTWindow, Window.TypeContainer.AccessibleAWTContainerComponent.AccessibleAWTComponent, Component.BaselineResizeBehavior, Component.BltBufferStrategy, Component.FlipBufferStrategy| Modifier and Type | Field and Description |
|---|---|
static int |
LOAD
This constant value indicates that the purpose of the file
dialog window is to locate a file from which to read.
|
static int |
SAVE
This constant value indicates that the purpose of the file
dialog window is to locate a file to which to write.
|
DEFAULT_MODALITY_TYPEBOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENTgetOwnerlessWindows, getWindows| Constructor and Description |
|---|
FileDialog(Dialog parent)
Creates a file dialog for loading a file.
|
FileDialog(Dialog parent,
java.lang.String title)
Creates a file dialog window with the specified title for loading
a file.
|
FileDialog(Dialog parent,
java.lang.String title,
int mode)
Creates a file dialog window with the specified title for loading
or saving a file.
|
FileDialog(Frame parent)
Creates a file dialog for loading a file.
|
FileDialog(Frame parent,
java.lang.String title)
Creates a file dialog window with the specified title for loading
a file.
|
FileDialog(Frame parent,
java.lang.String title,
int mode)
Creates a file dialog window with the specified title for loading
or saving a file.
|
| Modifier and Type | Method and Description |
|---|---|
void |
addNotify()
Creates the file dialog's peer.
|
java.lang.String |
getDirectory()
Gets the directory of this file dialog.
|
java.lang.String |
getFile()
Gets the selected file of this file dialog.
|
java.io.FilenameFilter |
getFilenameFilter()
Determines this file dialog's filename filter.
|
java.io.File[] |
getFiles()
Returns files that the user selects.
|
int |
getMode()
Indicates whether this file dialog box is for loading from a file
or for saving to a file.
|
boolean |
isMultipleMode()
Returns whether the file dialog allows the multiple file selection.
|
protected java.lang.String |
paramString()
Returns a string representing the state of this
FileDialog
window. |
void |
setDirectory(java.lang.String dir)
Sets the directory of this file dialog window to be the
specified directory.
|
void |
setFile(java.lang.String file)
Sets the selected file for this file dialog window to be the
specified file.
|
void |
setFilenameFilter(java.io.FilenameFilter filter)
Sets the filename filter for this file dialog window to the
specified filter.
|
void |
setMode(int mode)
Sets the mode of the file dialog.
|
void |
setMultipleMode(boolean enable)
Enables or disables multiple file selection for the file dialog.
|
getAccessibleContext, getModalityType, getTitle, hide, isModal, isResizable, isUndecorated, setBackground, setModal, setModalityType, setOpacity, setResizable, setShape, setTitle, setUndecorated, setVisible, show, toBackaddPropertyChangeListener, addPropertyChangeListener, addWindowFocusListener, addWindowListener, addWindowStateListener, applyResourceBundle, applyResourceBundle, createBufferStrategy, createBufferStrategy, dispose, getBackground, getBufferStrategy, getFocusableWindowState, getFocusCycleRootAncestor, getFocusOwner, getFocusTraversalKeys, getIconImages, getInputContext, getListeners, getLocale, getModalExclusionType, getMostRecentFocusOwner, getOpacity, getOwnedWindows, getOwner, getShape, getToolkit, getType, getWarningString, getWindowFocusListeners, getWindowListeners, getWindowStateListeners, isActive, isAlwaysOnTop, isAlwaysOnTopSupported, isAutoRequestFocus, isFocusableWindow, isFocusCycleRoot, isFocused, isLocationByPlatform, isOpaque, isShowing, isValidateRoot, pack, paint, postEvent, processEvent, processWindowEvent, processWindowFocusEvent, processWindowStateEvent, removeNotify, removeWindowFocusListener, removeWindowListener, removeWindowStateListener, reshape, setAlwaysOnTop, setAutoRequestFocus, setBounds, setBounds, setCursor, setFocusableWindowState, setFocusCycleRoot, setIconImage, setIconImages, setLocation, setLocation, setLocationByPlatform, setLocationRelativeTo, setMinimumSize, setModalExclusionType, setSize, setSize, setType, toFrontadd, add, add, add, add, addContainerListener, addImpl, applyComponentOrientation, areFocusTraversalKeysSet, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getAlignmentX, getAlignmentY, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getComponentZOrder, getContainerListeners, getFocusTraversalPolicy, getInsets, getLayout, getMaximumSize, getMinimumSize, getMousePosition, getPreferredSize, insets, invalidate, isAncestorOf, isFocusCycleRoot, isFocusTraversalPolicyProvider, isFocusTraversalPolicySet, layout, list, list, locate, minimumSize, paintComponents, preferredSize, print, printComponents, processContainerEvent, remove, remove, removeAll, removeContainerListener, setComponentZOrder, setFocusTraversalKeys, setFocusTraversalPolicy, setFocusTraversalPolicyProvider, setFont, setLayout, transferFocusDownCycle, update, validate, validateTreeaction, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addMouseWheelListener, bounds, checkImage, checkImage, coalesceEvents, contains, contains, createImage, createImage, createVolatileImage, createVolatileImage, disable, disableEvents, dispatchEvent, enable, enable, enableEvents, enableInputMethods, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getBaseline, getBaselineResizeBehavior, getBounds, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusListeners, getFocusTraversalKeysEnabled, getFont, getFontMetrics, getForeground, getGraphics, getGraphicsConfiguration, getHeight, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocation, getLocation, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMousePosition, getMouseWheelListeners, getName, getParent, getPeer, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getSize, getTreeLock, getWidth, getX, getY, gotFocus, handleEvent, hasFocus, imageUpdate, inside, isBackgroundSet, isCursorSet, isDisplayable, isDoubleBuffered, isEnabled, isFocusable, isFocusOwner, isFocusTraversable, isFontSet, isForegroundSet, isLightweight, isMaximumSizeSet, isMinimumSizeSet, isPreferredSizeSet, isValid, isVisible, keyDown, keyUp, list, list, list, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, prepareImage, prepareImage, printAll, processComponentEvent, processFocusEvent, processHierarchyBoundsEvent, processHierarchyEvent, processInputMethodEvent, processKeyEvent, processMouseEvent, processMouseMotionEvent, processMouseWheelEvent, remove, removeComponentListener, removeFocusListener, removeHierarchyBoundsListener, removeHierarchyListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeMouseWheelListener, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, repaint, requestFocus, requestFocus, requestFocusInWindow, requestFocusInWindow, resize, resize, revalidate, setComponentOrientation, setDropTarget, setEnabled, setFocusable, setFocusTraversalKeysEnabled, setForeground, setIgnoreRepaint, setLocale, setMaximumSize, setName, setPreferredSize, show, size, toString, transferFocus, transferFocusBackward, transferFocusUpCycleFileDialog(parent, "", LOAD).parent - the owner of the dialogFileDialog(parent, title, LOAD).parent - the owner of the dialogtitle - the title of the dialog
If the value of mode is LOAD, then the
file dialog is finding a file to read, and the files shown are those
in the current directory. If the value of
mode is SAVE, the file dialog is finding
a place to write a file.
FileDialog(parent, "", LOAD).parent - the owner of the dialogjava.lang.IllegalArgumentException - if the parent's
GraphicsConfiguration
is not from a screen device;java.lang.IllegalArgumentException - if parent
is null; this exception is always thrown when
GraphicsEnvironment.isHeadless
returns trueGraphicsEnvironment.isHeadless()FileDialog(parent, title, LOAD).parent - the owner of the dialogtitle - the title of the dialog; a null value
will be accepted without causing a
NullPointerException to be thrownjava.lang.IllegalArgumentException - if the parent's
GraphicsConfiguration
is not from a screen device;java.lang.IllegalArgumentException - if parent
is null; this exception is always thrown when
GraphicsEnvironment.isHeadless
returns trueGraphicsEnvironment.isHeadless()
If the value of mode is LOAD, then the
file dialog is finding a file to read, and the files shown are those
in the current directory. If the value of
mode is SAVE, the file dialog is finding
a place to write a file.
parent - the owner of the dialogtitle - the title of the dialog; a null value
will be accepted without causing a
NullPointerException to be thrownmode - the mode of the dialog; either
FileDialog.LOAD or FileDialog.SAVEjava.lang.IllegalArgumentException - if an illegal
file dialog mode is supplied;java.lang.IllegalArgumentException - if the parent's
GraphicsConfiguration
is not from a screen device;java.lang.IllegalArgumentException - if parent
is null; this exception is always thrown when
GraphicsEnvironment.isHeadless
returns trueGraphicsEnvironment.isHeadless(),
LOAD,
SAVEaddNotify in class DialogComponent.isDisplayable(),
Window.removeNotify()FileDialog.LOAD or
FileDialog.SAVELOAD,
SAVE,
setMode(int)mode is not
a legal value, an exception will be thrown and mode
will not be set.null or invalid)
directory of this FileDialogsetDirectory(java.lang.String)null or an
invalid directory implies an implementation-defined default.
This default will not be realized, however, until the user
has selected a file. Until this point, getDirectory()
will return the value passed into this method.
Specifying "" as the directory is exactly equivalent to
specifying null as the directory.
dir - the specified directorygetDirectory()CANCEL, the returned file is null.null if none is selectedsetFile(java.lang.String)If the user cancels the file dialog, then the method returns an empty array.
setFile(String),
getFile()
Specifying "" as the file is exactly equivalent to specifying
null
as the file.
file - the file being setgetFile(),
getFiles()enable - if true, multiple file selection is enabled;
false - disabled.isMultipleMode()true if the file dialog allows the multiple
file selection; false otherwise.setMultipleMode(boolean)FilenameFilter,
setFilenameFilter(java.io.FilenameFilter)filter - the specified filterFilenameFilter,
getFilenameFilter()FileDialog
window. This method is intended to be used only for debugging purposes,
and the content and format of the returned string may vary between
implementations. The returned string may be empty but may not be
null.paramString in class Dialog