java.awt
Class FileDialog

java.lang.Object
  |
  +--java.awt.Component
        |
        +--java.awt.Container
              |
              +--java.awt.Window
                    |
                    +--java.awt.Dialog
                          |
                          +--java.awt.FileDialog

public class FileDialog
extends Dialog

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.

Since:
JDK1.0
See Also:
Window.show(), Serialized Form

Inner classes inherited from class java.awt.Component
Component.AWTTreeLock, Component.NativeInLightFixer
 
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
base, modal, nameCounter, resizable, serialVersionUID, title
 
Fields inherited from class java.awt.Window
active, base, focusMgr, inputContext, nameCounter, OPENED, ownedWindowList, serialVersionUID, state, warningString, weakThis, windowListener, windowSerializedDataVersion
 
Fields inherited from class java.awt.Container
component, containerListener, containerSerializedDataVersion, dispatcher, layoutMgr, maxSize, ncomponents, serialVersionUID
 
Fields inherited from class java.awt.Component
actionListenerK, adjustmentListenerK, appContext, assert, background, BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, changeSupport, componentListener, componentListenerK, componentOrientation, componentSerializedDataVersion, containerListenerK, cursor, dropTarget, enabled, eventMask, focusListener, focusListenerK, font, foreground, hasFocus, height, incRate, inputMethodListener, inputMethodListenerK, isInc, isPacked, itemListenerK, keyListener, keyListenerK, LEFT_ALIGNMENT, locale, LOCK, minSize, mouseListener, mouseListenerK, mouseMotionListener, mouseMotionListenerK, name, nameExplicitlySet, newEventsOnly, ownedWindowK, parent, peer, peerFont, popups, prefSize, RIGHT_ALIGNMENT, serialVersionUID, textListenerK, TOP_ALIGNMENT, valid, visible, width, windowListenerK, x, y
 
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
(package private) static void ()
           
 void addNotify()
          Creates the file dialog's peer.
(package private)  String constructComponentName()
          Construct 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 the parameter string representing the state of this file dialog window.
(package private)  boolean postsOldMouseEvents()
           
private  void readObject(ObjectInputStream s)
           
(package private)  void setDirectory_NoClientCode(String dir)
           
 void setDirectory(String dir)
          Sets the directory of this file dialog window to be the specified directory.
(package private)  void setFile_NoClientCode(String file)
           
 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
getTitle, isModal, isResizable, setModal, setResizable, setTitle, show
 
Methods inherited from class java.awt.Window
addOwnedWindow, addWindowListener, applyResourceBundle, applyResourceBundle, connectOwnedWindow, dispatchEventImpl, dispose, eventEnabled, finalize, getFocusOwner, getInputContext, getLocale, getOwnedWindows, getOwner, getToolkit, getWarningString, isActive, isShowing, nextFocus, ownedInit, pack, postEvent, postProcessKeyEvent, postWindowEvent, preProcessKeyEvent, processEvent, processWindowEvent, removeOwnedWindow, removeWindowListener, setFocusOwner, setWarningString, toBack, toFront, transferFocus, writeObject
 
Methods inherited from class java.awt.Container
add, add, add, add, add, addContainerListener, addImpl, applyOrientation, countComponents, deliverEvent, dispatchEventToSelf, doLayout, findComponentAt, findComponentAt, getAlignmentX, getAlignmentY, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents_NoClientCode, getComponents, getInsets, getLayout, getMaximumSize, getMinimumSize, getMouseEventTarget, getPreferredSize, getWindow, insets, invalidate, invalidateTree, isAncestorOf, layout, lightweightPrint, list, list, locate, minimumSize, paint, paintComponents, preferredSize, print, printComponents, printOneComponent, processContainerEvent, proxyEnableEvents, proxyRequestFocus, remove, remove, removeAll, removeContainerListener, removeNotify, setFont, setLayout, update, validate, validateTree
 
Methods inherited from class java.awt.Component
action, add, addComponentListener, addFocusListener, addInputMethodListener, addKeyListener, addMouseListener, addMouseMotionListener, addPropertyChangeListener, addPropertyChangeListener, areInputMethodsEnabled, bounds, checkImage, checkImage, coalesceEvents, contains, contains, createImage, createImage, disable, disableEvents, dispatchEvent, enable, enable, enableEvents, enableInputMethods, firePropertyChange, getBackground, getBounds, getBounds, getColorModel, getComponentOrientation, getCursor, getDropTarget, getFont_NoClientCode, getFont, getFontMetrics, getForeground, getGraphics, getHeight, getInputMethodRequests, getLocation, getLocation, getLocationOnScreen, getName, getNativeContainer, getParent_NoClientCode, getParent, getPeer, getSize, getSize, getToolkitImpl, getTreeLock, getWidth, getWindowForObject, getX, getY, gotFocus, handleEvent, hasFocus, hide, imageUpdate, inside, isDisplayable, isDoubleBuffered, isEnabled, isEnabledImpl, isFocusTraversable, isLightweight, isOpaque, isValid, isVisible, keyDown, keyUp, list, list, list, location, lostFocus, mouseDown, mouseDrag, mouseEnter, mouseExit, mouseMove, mouseUp, move, nextFocus, paintAll, prepareImage, prepareImage, printAll, processComponentEvent, processFocusEvent, processInputMethodEvent, processKeyEvent, processMouseEvent, processMouseMotionEvent, remove, removeComponentListener, removeFocusListener, removeInputMethodListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removePropertyChangeListener, removePropertyChangeListener, repaint, repaint, repaint, repaint, requestFocus, reshape, resize, resize, setBackground, setBounds, setBounds, setComponentOrientation, setCursor, setDropTarget, setEnabled, setForeground, setLocale, setLocation, setLocation, setName, setSize, setSize, setVisible, show, size, toString, transferFocus
 
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, registerNatives, wait, wait, wait
 

Field Detail

LOAD

public static final int LOAD
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
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
Constructor Detail

FileDialog

public FileDialog(Frame parent)
Creates a file dialog for loading a file. The title of the file dialog is initially empty.
Parameters:
parent - the owner of the dialog
Since:
JDK1.1

FileDialog

public FileDialog(Frame parent,
                  String title)
Creates a file dialog window with the specified title for loading a file. The files shown are those in the current directory.
Parameters:
parent - the owner of the dialog.
title - the title of the dialog.

FileDialog

public FileDialog(Frame parent,
                  String title,
                  int mode)
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. If the value of mode is SAVE, the file dialog is finding a place to write a file.

Parameters:
parent - the owner of the dialog.
title - the title of the dialog.
mode - the mode of the dialog.
See Also:
LOAD, SAVE
Method Detail

static void ()

initIDs

private static void initIDs()
Initialize JNI field and method IDs for fields that may be accessed from C.

constructComponentName

String constructComponentName()
Construct a name for this component. Called by getName() when the name is null.
Overrides:
constructComponentName in class Dialog

addNotify

public void addNotify()
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

getMode

public int getMode()
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:
LOAD, SAVE, setMode(int)

setMode

public void setMode(int mode)
Sets the mode of the file dialog.
Parameters:
mode - the mode for this file dialog, either FileDialog.LOAD or FileDialog.SAVE.
Throws:
IllegalArgumentException - if an illegal file dialog mode is used.
Since:
JDK1.1
See Also:
LOAD, SAVE, getMode()

getDirectory

public String getDirectory()
Gets the directory of this file dialog.
Returns:
the (potentially null or invalid) directory of this FileDialog.
See Also:
setDirectory(java.lang.String)

setDirectory

public void setDirectory(String dir)
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 specific directory.
See Also:
getDirectory()

setDirectory_NoClientCode

final void setDirectory_NoClientCode(String dir)

getFile

public String getFile()
Gets the selected file of this file dialog.
Returns:
the currently selected file of this file dialog window, or null if none is selected.
See Also:
setFile(java.lang.String)

setFile

public void setFile(String file)
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:
getFile()

setFile_NoClientCode

final void setFile_NoClientCode(String file)

getFilenameFilter

public FilenameFilter getFilenameFilter()
Determines this file dialog's filename filter. A filename filter allows the user to specify which files appear in the file dialog window.
Returns:
this file dialog's filename filter.
See Also:
FilenameFilter, setFilenameFilter(java.io.FilenameFilter)

setFilenameFilter

public void setFilenameFilter(FilenameFilter filter)
Sets the filename filter for this file dialog window to the specified filter.
Parameters:
filter - the specified filter.
See Also:
FilenameFilter, getFilenameFilter()

readObject

private void readObject(ObjectInputStream s)
                 throws ClassNotFoundException,
                        IOException
Overrides:
readObject in class Window

paramString

protected String paramString()
Returns the parameter string representing the state of this file dialog window. This string is useful for debugging.
Returns:
the parameter string of this file dialog window.
Overrides:
paramString in class Dialog

postsOldMouseEvents

boolean postsOldMouseEvents()
Overrides:
postsOldMouseEvents in class Container