-
Bug
-
Resolution: Fixed
-
P3
-
1.3.0
-
beta
-
generic, x86
-
generic, windows_95, windows_98, windows_nt
Name: skT88420 Date: 09/14/99
1. Just using \JDK1.3demo\JFileChooserDemo\JFileChooserDemo.jar. When"open
Dialog" or "save Dialog" opened,I select one file named "1234" in List of D
ialog, then change "4321" in the Field "File name", select "metal" or "wind
ows" RadioButton. After click open or save button,I always get message "No
file was chosen"! if I use Motif UI, it's OK.
2. The source code is:
public void actionPerformed(ActionEvent e) {
int retval = chooser.showDialog(frame, null);
if(retval == JFileChooser.APPROVE_OPTION) {
File theFile = chooser.getSelectedFile();
if(theFile != null) {
if(theFile.isDirectory()) {
JOptionPane.showMessageDialog(
frame, "You chose this directory: " +
chooser.getSelectedFile().getAbsolutePath()
);
} else {
=09=09 JOptionPane.showMessageDialog(
=09=09=09frame, "You chose this file: " +
=09=09=09chooser.getSelectedFile().getAbsolutePath()
=09=09 );
=09=09}
=09=09return;
=09 }
=09}
=09JOptionPane.showMessageDialog(frame, "No file was chosen.");
}
3. None.
4.None.
5.The output of the commands "java -version" is:
java version "1.3beta"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.3beta-O)
Java*TM) HotSpot Client VM (build 1.3beta-O,mixed mode)
The output of the commands "java -fullversion" is:
java full version "1.3beta-O"
(Review ID: 95141)=20
======================================================================
Name: skT88420 Date: 09/24/99
1.
Create a JFileChooser, call showSaveDialog().
getSelectedFile() returns null, if the file to save to does not yet exist.
Earlier versions of JDK return a valid filehandle.
2.
...
JFileChooser filechooser = new JFileChooser();
filechooser.rescanCurrentDirectory();
int returnVal = filechooser.showSaveDialog(this);
if (returnVal == JFileChooser.APPROVE_OPTION) {
File file = filechooser.getSelectedFile();
System.out.println("filechooser.getSelectedFile()="+file);
if (file != null) {
someJComponent.setText(filechooser.getSelectedFile().getAbsolutePath());
}
}
...
3.
Nullpointer exceptions occur, if getSelectedFile == null is not checked.
4.
Works in JDK 1.2.x.
5.
C:>java -version
java version "1.3beta"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.3beta-O)
Java(TM) HotSpot Client VM (build 1.3beta-O, mixed mode)
C:\>java -fullversion
java full version "1.3beta-O"
6.
-
(Review ID: 95696)
======================================================================
Name: skT88420 Date: 10/11/99
JFileChooser is broken if we click a file and then change the filename
in the text area we can no longer say getSelectedFile it returns null.
(Review ID: 96367)
======================================================================
Name: krT82822 Date: 12/04/99
java version "1.3beta"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.3beta-O)
Java(TM) HotSpot Client VM (build 1.3beta-O, mixed mode)
JFileChooser jfc;
....
File file = jfc.getSelectedFile();
returns null even if a valid filename was entered in the
filename TextField.
This happens only if a file was first choosen from a list
and then manually changed in the TextField.
(Review ID: 98645)
======================================================================
Name: skT88420 Date: 01/24/2000
% java -version
java version "1.3beta"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.3beta-0)
Java(TM) HotSpot Client VM (build 1.3beta-0, mixed mode)
In JFileChooser save dialog, choose a file from the list and
then type in a different name in the bottom. After clicking save,
the getSelectedFile() call returns null.
(Review ID: 100304)
======================================================================
- duplicates
-
JDK-4271670 JFileChooser.getSelectedFile() return null in JDK1.3 beta
-
- Closed
-
- relates to
-
JDK-4300582 Can not Save file as a new file(NullPointerException)
-
- Closed
-