PDAP Public Review Draft

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:
ImageObserver, MenuContainer

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()

Field Summary
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.
 
Fields inherited from class java.awt.Component
BOTTOM_ALIGNMENT, CENTER_ALIGNMENT, LEFT_ALIGNMENT, RIGHT_ALIGNMENT, TOP_ALIGNMENT
 
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, 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.
 
Method Summary
 java.lang.String getDirectory()
          Gets the directory of this file dialog.
 java.lang.String getFile()
          Gets the selected file of this file dialog.
 int getMode()
          Indicates whether this file dialog box is for loading from a file or for saving to a file.
protected  java.lang.String paramString()
          Returns the parameter string representing the state of this file dialog 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 setMode(int mode)
          Sets the mode of the file dialog.
 
Methods inherited from class java.awt.Dialog
dispose, getTitle, hide, isModal, isResizable, setModal, setResizable, setTitle, show
 
Methods inherited from class java.awt.Window
addWindowListener, finalize, getFocusOwner, getLocale, getToolkit, getWarningString, isShowing, pack, postEvent, processEvent, processWindowEvent, removeWindowListener, setCursor, toBack, toFront
 
Methods inherited from class java.awt.Container
add, add, add, add, add, addContainerListener, addImpl, countComponents, deliverEvent, doLayout, findComponentAt, findComponentAt, getAlignmentX, getAlignmentY, getComponent, getComponentAt, getComponentAt, getComponentCount, getComponents, getInsets, getLayout, getMaximumSize, getMinimumSize, getPreferredSize, insets, invalidate, isAncestorOf, layout, list, list, locate, minimumSize, paint, paintComponents, preferredSize, print, printComponents, processContainerEvent, remove, remove, removeAll, removeContainerListener, setFont, setLayout, update, validate, validateTree
 
Methods inherited from class java.awt.Component
action, add, addComponentListener, addFocusListener, addKeyListener, addMouseListener, addMouseMotionListener, addNotify, bounds, checkImage, checkImage, coalesceEvents, contains, contains, createImage, createImage, disable, disableEvents, dispatchEvent, enable, enable, enableEvents, getBackground, getBounds, getColorModel, getCursor, getFont, getFontMetrics, getForeground, getGraphics, getGraphicsConfiguration, getHeight, getLocation, getLocation, getLocationOnScreen, getName, getParent, getSize, getSize, getTreeLock, getWidth, getX, getY, gotFocus, handleEvent, hasFocus, imageUpdate, inside, isDisplayable, isDoubleBuffered, isEnabled, 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, processKeyEvent, processMouseEvent, processMouseMotionEvent, remove, removeComponentListener, removeFocusListener, removeKeyListener, removeMouseListener, removeMouseMotionListener, removeNotify, repaint, repaint, repaint, repaint, requestFocus, reshape, resize, resize, setBackground, setBounds, setBounds, setEnabled, setForeground, setLocale, setLocation, setLocation, setName, setSize, setSize, setVisible, show, size, toString, transferFocus
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, 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.

Value 0 is assigned to LOAD.


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.

Value 1 is assigned to SAVE.

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,
                  java.lang.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,
                  java.lang.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

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:
java.lang.IllegalArgumentException - if an illegal file dialog mode is used.
Since:
JDK1.1
See Also:
LOAD, SAVE, getMode()

getDirectory

public java.lang.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(java.lang.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()

getFile

public java.lang.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(java.lang.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()

paramString

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

PDAP 1.0 Spec, Rev. 0.16