java.awt
Class FileDialog
java.lang.Object
|
+--java.awt.Component
|
+--java.awt.Container
|
+--java.awt.Window
|
+--java.awt.Dialog
|
+--java.awt.FileDialog
- All Implemented Interfaces:
- Accessible, java.awt.image.ImageObserver, MenuContainer, Serializable
- public class FileDialog
- extends Dialog
Unsafe:
- See Also:
- Serialized Form
Field Summary |
private static String |
base
|
(package private) String |
dir
|
(package private) String |
file
|
(package private) FilenameFilter |
filter
|
static int |
LOAD
Enabled: This constant value indicates that the purpose of the file
dialog window is to locate a file from which to read. |
(package private) int |
mode
|
private static int |
nameCounter
|
static int |
SAVE
Enabled: This constant value indicates that the purpose of the file
dialog window is to locate a file to which to write. |
private static long |
serialVersionUID
|
Fields inherited from class java.awt.Window |
inputContext, isFirstPack, OPENED, ownedWindowList, state, syncLWRequests, systemSyncLWRequests, warningString, windowFocusListener, windowListener, windowStateListener |
Fields inherited from class java.awt.Component |
accessibleContext, actionListenerK, adjustmentListenerK, appContext, background, BOTTOM_ALIGNMENT, bufferStrategy, CENTER_ALIGNMENT, componentListener, componentListenerK, componentOrientation, containerListenerK, cursor, dropTarget, enabled, eventMask, focusListener, focusListenerK, focusTraversalKeys, font, foreground, graphicsConfig, height, hierarchyBoundsListener, hierarchyBoundsListenerK, hierarchyListener, hierarchyListenerK, ignoreRepaint, incRate, inputMethodListener, inputMethodListenerK, isInc, isPacked, itemListenerK, keyListener, keyListenerK, LEFT_ALIGNMENT, locale, LOCK, metrics, minSize, mouseListener, mouseListenerK, mouseMotionListener, mouseMotionListenerK, mouseWheelListener, mouseWheelListenerK, newEventsOnly, ownedWindowK, parent, peer, peerFont, popups, prefSize, RIGHT_ALIGNMENT, textListenerK, TOP_ALIGNMENT, valid, visible, width, windowClosingException, windowFocusListenerK, windowListenerK, windowStateListenerK, x, y |
Constructor Summary |
FileDialog(Frame parent)
Enabled: Creates a file dialog for loading a file. |
FileDialog(Frame parent,
String title)
Enabled: Creates a file dialog window with the specified title for loading
a file. |
FileDialog(Frame parent,
String title,
int mode)
Enabled: Creates a file dialog window with the specified title for loading
or saving a file. |
Method Summary |
void |
addNotify()
Suppressed: Creates the file dialog's peer. |
(package private) String |
constructComponentName()
Constructs a name for this component. |
String |
getDirectory()
Enabled: Gets the directory of this file dialog. |
String |
getFile()
Enabled: Gets the selected file of this file dialog. |
FilenameFilter |
getFilenameFilter()
Enabled: Determines this file dialog's filename filter. |
int |
getMode()
Enabled: Indicates whether this file dialog box is for loading from a file
or for saving to a file. |
private static void |
initIDs()
Initialize JNI field and method IDs for fields that may be
accessed from C. |
protected String |
paramString()
Returns a string representing the state of this FileDialog
window. |
(package private) boolean |
postsOldMouseEvents()
|
private void |
readObject(ObjectInputStream s)
Reads the ObjectInputStream and performs
a backwards compatibility check by converting
either a dir or a file
equal to an empty string to null . |
void |
setDirectory(String dir)
Enabled: Sets the directory of this file dialog window to be the
specified directory. |
void |
setFile(String file)
Enabled: Sets the selected file for this file dialog window to be the
specified file. |
void |
setFilenameFilter(FilenameFilter filter)
Enabled: Sets the filename filter for this file dialog window to the
specified filter. |
void |
setMode(int mode)
Enabled: Sets the mode of the file dialog. |
Methods inherited from class java.awt.Dialog |
dispose, getAccessibleContext, getTitle, hide, interruptBlocking, isModal, isResizable, isUndecorated, setModal, setResizable, setTitle, setUndecorated, show |
Methods inherited from class java.awt.Window |
addOwnedWindow, addPropertyChangeListener, addPropertyChangeListener, addWindowFocusListener, addWindowListener, addWindowStateListener, adjustDecendantsOnParent, adjustListeningChildrenOnParent, applyResourceBundle, applyResourceBundle, clearMostRecentFocusOwnerOnHide, connectOwnedWindow, createBufferStrategy, createBufferStrategy, deliverMouseWheelToAncestor, dispatchEventImpl, dispatchMouseWheelToAncestor, eventEnabled, finalize, getBufferStrategy, getFocusableWindowState, getFocusCycleRootAncestor, getFocusOwner, getFocusTraversalKeys, getGraphicsConfiguration, getInputContext, getListeners, getLocale, getMostRecentFocusOwner, getOwnedWindows, getOwner, getToolkit, getWarningString, getWindowFocusListeners, getWindowListeners, getWindowStateListeners, isActive, isFocusableWindow, isFocusCycleRoot, isFocused, isShowing, pack, postEvent, postProcessKeyEvent, postWindowEvent, preProcessKeyEvent, processEvent, processWindowEvent, processWindowFocusEvent, processWindowStateEvent, removeOwnedWindow, removeWindowFocusListener, removeWindowListener, removeWindowStateListener, resetGC, setCursor, setFocusableWindowState, setFocusCycleRoot, setLocationRelativeTo, toBack, toFront |
Methods inherited from class java.awt.Container |
add, add, add, add, add, addContainerListener, addImpl, adjustDescendants, adjustListeningChildren, applyComponentOrientation, areFocusTraversalKeysSet, checkGD, clearCurrentFocusCycleRootOnHide, containsFocus, countComponents, countHierarchyMembers, createChildHierarchyEvents, createHierarchyEvents, deliverEvent, dispatchEventToSelf, doLayout, findComponentAt, findComponentAt, findComponentAt, get, getAccessibleAt, getAccessibleChild, getAccessibleChildrenCount, getAlignmentX, getAlignmentY, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents_NoClientCode, getComponents, getContainerListeners, getDropTargetEventTarget, getFocusTraversalPolicy, getInsets, getLayout, getMaximumSize, getMinimumSize, getMouseEventTarget, getPreferredSize, initializeFocusTraversalKeys, insets, invalidate, invalidateTree, isAncestorOf, isFocusCycleRoot, isFocusTraversalPolicySet, iterate, layout, lightweightPaint, lightweightPrint, list, list, locate, minimumSize, nextFocusHelper, numListening, paint, paintComponents, paintHeavyweightComponents, preferredSize, print, printComponents, printHeavyweightComponents, processContainerEvent, proxyEnableEvents, remove, remove, removeAll, removeContainerListener, removeNotify, setFocusTraversalKeys, setFocusTraversalPolicy, setFont, setLayout, setZOrder, size, transferFocusBackward, transferFocusDownCycle, update, validate, validateTree |
Methods inherited from class java.awt.Component |
action, add, addComponentListener, addFocusListener, addHierarchyBoundsListener, addHierarchyListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addMouseWheelListener, areInputMethodsEnabled, autoProcessMouseWheel, autoTransferFocus, bounds, checkImage, checkImage, checkWindowClosingException, coalesceEvents, contains, contains, createImage, createImage, createVolatileImage, createVolatileImage, disable, disableEvents, dispatchEvent, enable, enable, enableEvents, enableInputMethods, eventTypeEnabled, firePropertyChange, firePropertyChange, firePropertyChange, getAccessibleIndexInParent, getAccessibleStateSet, getBackBuffer, getBackground, getBounds, getBounds, getColorModel, getComponentListeners, getComponentOrientation, getCursor, getDropTarget, getFocusListeners, getFocusTraversalKeys_NoIDCheck, getFocusTraversalKeysEnabled, getFont_NoClientCode, getFont, getFontMetrics, getForeground, getGraphics, getHeight, getHierarchyBoundsListeners, getHierarchyListeners, getIgnoreRepaint, getInputMethodListeners, getInputMethodRequests, getKeyListeners, getLocation, getLocation, getLocationOnScreen_NoTreeLock, getLocationOnScreen, getMouseListeners, getMouseMotionListeners, getMouseWheelListeners, getName, getNativeContainer, getParent_NoClientCode, getParent, getPeer, getPropertyChangeListeners, getPropertyChangeListeners, getSize, getSize, getToolkitImpl, getTreeLock, getWidth, getX, getY, gotFocus, handleEvent, hasFocus, imageUpdate, inside, isBackgroundSet, isCursorSet, isDisplayable, isDoubleBuffered, isEnabled, isEnabledImpl, isFocusable, isFocusOwner, isFocusTraversable, isFocusTraversableOverridden, isFontSet, isForegroundSet, isLightweight, isOpaque, isRecursivelyVisible, 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, requestFocusHelper, requestFocusInWindow, requestFocusInWindow, reshape, resize, resize, setBackground, setBounds, setBounds, setComponentOrientation, setDropTarget, setEnabled, setFocusable, setFocusTraversalKeys_NoIDCheck, setFocusTraversalKeysEnabled, setForeground, setGCFromPeer, setIgnoreRepaint, setLocale, setLocation, setLocation, setName, setSize, setSize, setVisible, show, toString, transferFocus, transferFocus, transferFocusUpCycle, updateCursorImmediately |
LOAD
public static final int LOAD
- Enabled: This constant value indicates that the purpose of the file
dialog window is to locate a file from which to read.
SAVE
public static final int SAVE
- Enabled: This constant value indicates that the purpose of the file
dialog window is to locate a file to which to write.
mode
int mode
dir
String dir
file
String file
filter
FilenameFilter filter
base
private static final String base
nameCounter
private static int nameCounter
serialVersionUID
private static final long serialVersionUID
FileDialog
public FileDialog(Frame parent)
- Enabled: Creates a file dialog for loading a file. The title of the
file dialog is initially empty. This is a convenience method for
FileDialog(parent, "", LOAD)
.
- Parameters:
parent
- the owner of the dialog- Since:
- JDK1.1
FileDialog
public FileDialog(Frame parent,
String title)
- Enabled: Creates a file dialog window with the specified title for loading
a file. The files shown are those in the current directory.
This is a convenience method for
FileDialog(parent, title, LOAD)
.
- Parameters:
parent
- the owner of the dialogtitle
- the title of the dialog
FileDialog
public FileDialog(Frame parent,
String title,
int mode)
- Enabled: Creates a file dialog window with the specified title for loading
or saving a file.
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.
- Parameters:
parent
- the owner of the dialogtitle
- the title of the dialogmode
- the mode of the dialog; either
FileDialog.LOAD
or FileDialog.SAVE
- See Also:
java.awt.FileDialog#LOAD
,
java.awt.FileDialog#SAVE
initIDs
private static void initIDs()
- Initialize JNI field and method IDs for fields that may be
accessed from C.
constructComponentName
String constructComponentName()
- Constructs a name for this component. Called by
getName()
when the name is null
.
- Overrides:
constructComponentName
in class Dialog
addNotify
public void addNotify()
- Suppressed: Creates the file dialog's peer. The peer allows us to change the look
of the file dialog without changing its functionality.
- Overrides:
addNotify
in class Dialog
- See Also:
Component.isDisplayable()
,
Container.removeNotify()
getMode
public int getMode()
- Enabled: Indicates whether this file dialog box is for loading from a file
or for saving to a file.
- Returns:
- the mode of this file dialog window, either
FileDialog.LOAD
or
FileDialog.SAVE
- See Also:
java.awt.FileDialog#LOAD
,
java.awt.FileDialog#SAVE
,
java.awt.FileDialog#setMode
setMode
public void setMode(int mode)
- Enabled: Sets the mode of the file dialog. If
mode
is not
a legal value, an exception will be thrown and mode
will not be set.
- Parameters:
mode
- the mode for this file dialog, either
FileDialog.LOAD
or
FileDialog.SAVE
- Since:
- JDK1.1
- See Also:
java.awt.FileDialog#LOAD
,
java.awt.FileDialog#SAVE
,
java.awt.FileDialog#getMode
getDirectory
public String getDirectory()
- Enabled: Gets the directory of this file dialog.
- Returns:
- the (potentially
null
or invalid)
directory of this FileDialog
- See Also:
java.awt.FileDialog#setDirectory
setDirectory
public void setDirectory(String dir)
- Enabled: Sets the directory of this file dialog window to be the
specified directory. Specifying a
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.
- Parameters:
dir
- the specified directory- See Also:
java.awt.FileDialog#getDirectory
getFile
public String getFile()
- Enabled: Gets the selected file of this file dialog. If the user
selected
CANCEL
, the returned file is null
.
- Returns:
- the currently selected file of this file dialog window,
or
null
if none is selected - See Also:
java.awt.FileDialog#setFile
setFile
public void setFile(String file)
- Enabled: Sets the selected file for this file dialog window to be the
specified file. This file becomes the default file if it is set
before the file dialog window is first shown.
Specifying "" as the file is exactly equivalent to specifying
null
as the file.
- Parameters:
file
- the file being set- See Also:
java.awt.FileDialog#getFile
getFilenameFilter
public FilenameFilter getFilenameFilter()
- Enabled: Determines this file dialog's filename filter. A filename filter
allows the user to specify which files appear in the file dialog
window. Filename filters do not function in Sun's reference
implementation for Windows 95, 98, or NT 4.0.
- Returns:
- this file dialog's filename filter
- See Also:
java.io.FilenameFilter
,
java.awt.FileDialog#setFilenameFilter
setFilenameFilter
public void setFilenameFilter(FilenameFilter filter)
- Enabled: Sets the filename filter for this file dialog window to the
specified filter.
Filename filters do not function in Sun's reference
implementation for Windows 95, 98, or NT 4.0.
- Parameters:
filter
- the specified filter- See Also:
java.io.FilenameFilter
,
java.awt.FileDialog#getFilenameFilter
readObject
private void readObject(ObjectInputStream s)
throws ClassNotFoundException,
IOException
- Reads the
ObjectInputStream
and performs
a backwards compatibility check by converting
either a dir
or a file
equal to an empty string to null
.
- Parameters:
s
- the ObjectInputStream
to read
ClassNotFoundException
IOException
- See Also:
java.awt.GraphicsEnvironment#isHeadless
,
Window.writeObject(java.io.ObjectOutputStream)
paramString
protected String paramString()
- Returns a string representing the state of this
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
.
- Overrides:
paramString
in class Dialog
- Returns:
- the parameter string of this file dialog window
postsOldMouseEvents
boolean postsOldMouseEvents()
- Overrides:
postsOldMouseEvents
in class Container
comments?