-
Bug
-
Resolution: Fixed
-
P4
-
1.2.0
-
beta
-
generic
-
generic
Name: vi73552 Date: 04/28/99
When the JFileChooser is set to DIRECTORIES_ONLY mode and you
type in a directory name that doesn't exist, clicking "Open"
will not return the typed in text and close the dialog. If you
do the exact same thing when the file selection mode is set to
FILES_ONLY the dialog does close and what you typed in is returned.
Here's a small program you can use to see this. If you specify
any args on the invoke line then the file selection mode is
set to DIRECTORIES_ONLY(ie. java -cp . bug dirs).
//~~~~~~~~~~~~~~~~~~~~~~~~~~~ cut here ~~~~~~~~~~~~~~~~~~~~~~~
import javax.swing.*;
import java.awt.event.*;
public class bug {
public static void main (String args[]) {
final JFrame frame = new JFrame();
frame.addWindowListener(new WindowAdapter() {
public void windowClosing(WindowEvent e) {System.exit(0);}
});
final JFileChooser chooser = new JFileChooser();
final int args_len = args.length;
JButton btn = new JButton("Click Me");
btn.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) {
if (args_len > 0)
chooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY);
chooser.showOpenDialog(null);
System.out.println("SELECTED = " + chooser.getSelectedFile());
}
});
frame.getContentPane().add(btn);
frame.pack();
frame.setVisible(true);
}
}
(Review ID: 57557)
======================================================================