The FileDialog spec says the following about the
FileDialog(Frame,String,int) constructor:
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
The spec doesn't specify what the mode of the file dialog would be
if an illegal value is supplied for the mode parameter (for example,
if FileDialog(aFrame,"A FileDialog",100) is used to create the
file dialog).
The following application creates a file dialog by supplying 100
as the value for the mode parameter. When getMode() is invoked on
the file dialog, 100 is returned. According to the spec, only
FileDialog.LOAD and FileDialog.SAVE (ie, 0 and 1) are legal values for the
mode.
Since 100 (an illegal value for the mode) is returned by getMode(), the mode
of the file dialog is unknown and unspecified.
==============================================================================
/*
* FileDialogModeTest.java
* FileDialog spec does not specify behavior of
* FileDialog(Frame,String,int) constructor if
* illegal mode parameter is supplied
*
*/
import java.awt.*;
import java.awt.event.*;
public class FileDialogModeTest extends Frame implements ActionListener {
public void init() {
setSize(500, 400);
setTitle("FileDialog Mode Test");
setLayout(new FlowLayout());
Button b1 = new Button("Test FileDialog(p,t,m)");
b1.addActionListener(this);
add(b1);
Button b2 = new Button("Exit");
b2.addActionListener(this);
add(b2);
}
public static void main(String args[]) {
FileDialogModeTest fileDialogTest = new FileDialogModeTest();
fileDialogTest.init();
fileDialogTest.show();
}
public void actionPerformed(ActionEvent e) {
String nameb = e.getActionCommand();
if(nameb.equals("Test FileDialog(p,t,m)")) {
String s = "A FileDialog created with mode 100";
//int m = FileDialog.LOAD;
int m = 100;
FileDialog fd = new FileDialog(this, s, m);
System.out.println("*** FileDialog mode: " + fd.getMode());
fd.setVisible(true);
};
if(nameb.equals("Exit")) {
System.exit(0);
};
}
}
==============================================================================