-
Bug
-
Resolution: Fixed
-
P4
-
1.2.2
-
beta
-
x86
-
windows_nt
Name: skT88420 Date: 10/25/99
1.
a. Create a JFileChooser
b. Call showOpenDialog(), select a file and press "Open"
c. Call showOpenDialog() again on the same file chooser
and close the dialog using the close button in the corner.
It will return the result of the last call, in this case
APROVE_OPTION (as if "Open" had been pressed).
2. Trivial - but here goes:
import javax.swing.JFileChooser;
public class ChooserCheck {
public static void main(String[] args) {
JFileChooser fc = new JFileChooser();
System.out.println(fc.showOpenDialog(null));
System.out.println(fc.showOpenDialog(null));
System.exit(0);
}
}
3. N/A
4. In the first chooser dialog select a file and press "Open".
In the second chooser dialog close it using the X button
in the top-right corner.
The output is:
0
0
which is two APPROVE_OPTION's. Closing a chooser dialog
should be equivalent to cancelling.
5.
java version "1.2.2"
Classic VM (build JDK-1.2.2-W, native threads, symcjit)
java full version "JDK-1.2.2-W"
6.
Setting up filters etc. for a filechooser encourages re-use,
as does the fact that it retains the previous state (directory
etc.). However, the internal variable "returnValue" is never
reset (in JFileChooser.showDialog()), causing it to return
whatever result was returned by a previous call, if the
dialog is closed using the X button in the top-right corner.
To be consistent, JFileChooser.showDialog() should set
"returnValue" to ERROR_OPTION before the call to
JFileChooser.show() (or even better - treat closing the
dialog as a cancellation and return CANCEL_OPTION).
The problem is present in JDK 1.3beta as well.
(Review ID: 96882)
======================================================================