Reputation: 42880
I face the following strange problem while using JFileChooser
package sandbox;
import java.io.File;
import javax.swing.JFileChooser;
/**
*
* @author yccheok
*/
public class Main {
/**
* @param args the command line arguments
*/
public static void main(String[] args) {
final JFileChooser chooser = new JFileChooser();
chooser.setAcceptAllFileFilterUsed(false);
// STRANGE! Using "TEST", when dialog box pop up, you see empty in file name field.
// However, using other name like "TESTX", when dialog box pop up, you see "TESTX" in file name field.
//chooser.setSelectedFile(new File("TESTX"));
chooser.setSelectedFile(new File("TEST"));
chooser.showOpenDialog(null);
}
}
Is this my machine problem? Or you all face the same problem too? For your information, I am using Vista.
Upvotes: 0
Views: 139
Reputation: 78043
Maybe for some reason new File("TEST") returns null for you.
Run it in debug to see.
Upvotes: 0
Reputation: 170308
Both new File("TESTX")
and new File("TEST")
will display TESTX and TEST respectively in the text field of the JFileChooser (as expected).
Upvotes: 2