2.4.2 - File Chooser - JdlFileChooser

John W. Campbell Introduction

This class provides a file chooser dialogue window object with basic 'Open' or 'Save' functions. If an incorrect filename is given when opening a file, the user is given choices of cancelling the request or trying another file name. When saving a file, the user will have the opportunity to overwrite a file or to choose a new file name if the requested output file already exists. The object is a sub-class of the Java JFileChooser object.

Class, fields, constructor and methods:

Class Details
Accessible Fields
Method Class Details

Class name:
Class definition:
public class JdlFileChooser
none Accessible Fields

The following accessible fields have been defined:

public final static int OPEN_DIALOG
Open file for input flag.
public final static int SAVE_DIALOG
Open file to save flag.
public final static int DEFAULT_DIR
Default directory flag.
public final static int CURRENT_DIR
Current directory flag.
public final static int HOME_DIR
Home directory flag.
final static long serialVersionUID Constructor Introduction

A single constructor is available.


Standard constructor Standard constructor

Constructs a JdlFileChooser with the required resources.

Constructor Definition:
public JdlFileChooser(Component parent, String title, int idir, int type)
Parameters List:
The parent component for the file chooser dialogue window.
A title for the file chooser dialogue window.
The starting directory option which may be the user's default directory DEFAULT_DIR (operating system dependent), the current directory CURRENT_DIR or the home directory HOME_DIR.
The required type which may be OPEN_DIALOG to open an input file or SAVE_DIALOG to save (write) an output file. Method Introduction

This section contains methods a single method to choose an input or output file.


Choose file - chooseFile Choose file - chooseFile

This method requests the choice of a file name for either an input file or output (save) file depending on the type requested when the object was constructed. A brief description of the required file type and the required file extension are given.

Method Definition:
public File chooseFile(String filename, String ext, String description)
Parameters List:
An initial/default file name for the selection.
The required file name extension.
A brief description of the required file type for display in the dialogue.
Method Return:
A File object for the chosen file (null if the input was cancelled)

⇑ Up 2   ⇑ Up 1   ⇑ Top of this