|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object java.awt.Component java.awt.Container java.awt.Window java.awt.Dialog java.awt.FileDialog
The 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 FormNested Class Summary |
Nested classes inherited from class java.awt.Dialog |
Dialog.AccessibleAWTDialog, Dialog.WakingRunnable |
Nested classes inherited from class java.awt.Window |
Window.AccessibleAWTWindow |
Nested classes inherited from class java.awt.Container |
Container.AccessibleAWTContainer, Container.DropTargetEventTargetFilter, Container.EventTargetFilter, Container.MouseEventTargetFilter |
Nested classes inherited from class java.awt.Component |
Component.AccessibleAWTComponent, Component.AWTTreeLock, Component.BltBufferStrategy, Component.FlipBufferStrategy |
Field Summary | |
private static String |
base
|
(package private) String |
dir
|
(package private) String |
file
|
(package private) FilenameFilter |
filter
|
static int |
LOAD
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
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.Dialog |
modal, resizable, title, undecorated |
Fields inherited from class java.awt.Window |
beforeFirstShow, inputContext, OPENED, ownedWindowList, state, syncLWRequests, systemSyncLWRequests, warningString, windowFocusListener, windowListener, windowStateListener |
Fields inherited from class java.awt.Container |
component, containerListener, descendantsCount, INCLUDE_SELF, layoutMgr, listeningBoundsChildren, listeningChildren, ncomponents, SEARCH_HEAVYWEIGHTS |
Fields inherited from interface java.awt.image.ImageObserver |
ABORT, ALLBITS, ERROR, FRAMEBITS, HEIGHT, PROPERTIES, SOMEBITS, WIDTH |
Constructor Summary | |
FileDialog(Frame parent)
Creates a file dialog for loading a file. |
|
FileDialog(Frame parent,
String title)
Creates a file dialog window with the specified title for loading a file. |
|
FileDialog(Frame parent,
String title,
int mode)
Creates a file dialog window with the specified title for loading or saving a file. |
Method Summary | |
void |
addNotify()
Creates the file dialog's peer. |
(package private) String |
constructComponentName()
Constructs a name for this component. |
String |
getDirectory()
Gets the directory of this file dialog. |
String |
getFile()
Gets the selected file of this file dialog. |
FilenameFilter |
getFilenameFilter()
Determines this file dialog's filename filter. |
int |
getMode()
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)
Sets the directory of this file dialog window to be the specified directory. |
void |
setFile(String file)
Sets the selected file for this file dialog window to be the specified file. |
void |
setFilenameFilter(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. |
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.lang.Object |
clone, equals, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Field Detail |
public static final int LOAD
public static final int SAVE
int mode
String dir
String file
FilenameFilter filter
private static final String base
private static int nameCounter
private static final long serialVersionUID
Constructor Detail |
public FileDialog(Frame parent)
FileDialog(parent, "", LOAD)
.
parent
- the owner of the dialogpublic FileDialog(Frame parent, String title)
FileDialog(parent, title, LOAD)
.
parent
- the owner of the dialogtitle
- the title of the dialogpublic FileDialog(Frame parent, String title, int mode)
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 dialogmode
- the mode of the dialog; either
FileDialog.LOAD
or FileDialog.SAVE
IllegalArgumentException
- if an illegal file
dialog mode is suppliedLOAD
,
SAVE
Method Detail |
private static void initIDs()
String constructComponentName()
getName()
when the name is null
.
constructComponentName
in class Dialog
public void addNotify()
addNotify
in class Dialog
Component.isDisplayable()
,
Container.removeNotify()
public int getMode()
FileDialog.LOAD
or
FileDialog.SAVE
LOAD
,
SAVE
,
setMode(int)
public void setMode(int mode)
mode
is not
a legal value, an exception will be thrown and mode
will not be set.
mode
- the mode for this file dialog, either
FileDialog.LOAD
or
FileDialog.SAVE
IllegalArgumentException
- if an illegal file
dialog mode is suppliedLOAD
,
SAVE
,
getMode()
public String getDirectory()
null
or invalid)
directory of this FileDialog
setDirectory(java.lang.String)
public void setDirectory(String dir)
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()
public String getFile()
CANCEL
, the returned file is null
.
null
if none is selectedsetFile(java.lang.String)
public void setFile(String file)
Specifying "" as the file is exactly equivalent to specifying
null
as the file.
file
- the file being setgetFile()
public FilenameFilter getFilenameFilter()
FilenameFilter
,
setFilenameFilter(java.io.FilenameFilter)
public void setFilenameFilter(FilenameFilter filter)
filter
- the specified filterFilenameFilter
,
getFilenameFilter()
private void readObject(ObjectInputStream s) throws ClassNotFoundException, IOException
ObjectInputStream
and performs
a backwards compatibility check by converting
either a dir
or a file
equal to an empty string to null
.
s
- the ObjectInputStream
to read
ClassNotFoundException
IOException
protected String paramString()
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
boolean postsOldMouseEvents()
postsOldMouseEvents
in class Container
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |