jewl
Class FileDialog

java.lang.Object
  extended byjewl.Window
      extended byjewl.Container
          extended byjewl.Dialog
              extended byjewl.FileDialog
Direct Known Subclasses:
OpenDialog, SaveDialog

public abstract class FileDialog
extends Dialog

The abstract base class for the standard file-chooser dialogs. The dialog has Accept and Cancel buttons, and its execute() method will return a specified command character if the dialog is closed by pressing the Accept button, or the null character '\0' otherwise.


Constructor Summary
FileDialog(java.lang.String title, char action)
          Construct a new file-chooser dialog.
 
Method Summary
 void addFilter(java.lang.String[] extensions, java.lang.String description)
          Insert a new file filter into the dialog.
 void addFilter(java.lang.String extension, java.lang.String description)
          Add a new file filter into the dialog.
abstract  char execute()
          Execute the dialog to allow a file to be chosen.
 java.lang.String getDirectory()
          Get the full pathname of the current directory being used by this dialog.
 java.io.File getFile()
          Get the file that was selected using this dialog.
 java.lang.String getName()
          Get the full pathname of the file that was selected using this dialog.
 void setDirectory(java.lang.String name)
          Set the initial directory that will be displayed when the dialog is executed.
 void setLocation(int left, int top)
          Set the location of this dialog.
 void setSize(int width, int height)
          Set the size of this dialog.
 
Methods inherited from class jewl.Dialog
error, error, getString, getString, getTitle, message, message, query, query, setTitle, setValidator, show
 
Methods inherited from class jewl.Container
getBorderHeight, getBorderWidth, getInteriorHeight, getInteriorWidth
 
Methods inherited from class jewl.Window
addEventListener, commandAvailable, getCommand, getFont, getHeight, getID, getLeft, getScreenHeight, getScreenWidth, getSource, getTop, getWidth, hide, init, isVisible, nextCommand, parent, root, setFont, setID, show
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

FileDialog

public FileDialog(java.lang.String title,
                  char action)
Construct a new file-chooser dialog. Unlike other windows, standard dialogs have a preset size, so you do not need to specify an initial width and height.

Parameters:
title - the title displayed in the dialog's title bar.
action - the command code generated when the dialog is closed using the "Accept" button.
Method Detail

setSize

public void setSize(int width,
                    int height)
Set the size of this dialog. File dialogs cannot be resized, so this method does nothing.

Overrides:
setSize in class Window
Parameters:
width - ignored.
height - ignored.

setLocation

public void setLocation(int left,
                        int top)
Set the location of this dialog. File dialogs cannot be moved, so this method does nothing.

Overrides:
setLocation in class Window
Parameters:
left - ignored.
top - ignored.

execute

public abstract char execute()
Execute the dialog to allow a file to be chosen.

Overrides:
execute in class Dialog
Returns:
The command code for the "accept" button, or '\0' if the dialog was cancelled.

getName

public java.lang.String getName()
Get the full pathname of the file that was selected using this dialog.

Returns:
The full pathname of the selected file.

getFile

public java.io.File getFile()
Get the file that was selected using this dialog.

Returns:
The selected file.

setDirectory

public void setDirectory(java.lang.String name)
Set the initial directory that will be displayed when the dialog is executed.

Parameters:
name - the directory name to select.

getDirectory

public java.lang.String getDirectory()
Get the full pathname of the current directory being used by this dialog.

Returns:
The full pathname of the current directory.

addFilter

public void addFilter(java.lang.String extension,
                      java.lang.String description)
Add a new file filter into the dialog. The filter consists of a file extension (with or without a leading ".") and a description of the corresponding files. This allows the user to restrict the files shown in a file dialog to just those with a matching extension. The last filter added will be the one which is initially selected.

Parameters:
extension - the desired file extension, with or without a leading dot.
description - a description of the type of file selected by this filter.

addFilter

public void addFilter(java.lang.String[] extensions,
                      java.lang.String description)
Insert a new file filter into the dialog. The filter consists of an array of file extensions (with or without a leading ".") and a description of the corresponding files. This allows the user to restrict the files shown in a file dialog to just those with a matching extension. The last filter added will be the one which is initially selected.

Parameters:
extensions - an array containing the desired file extensions, with or without leading dots.
description - a description of the type of file selected by this filter.