Relates :
|
|
Relates :
|
|
Relates :
|
The "getSelectedFile()" method is supposed to return the selected file. A valid method to select a file is for the user to type the filename into the UI. However, this method returns only the file that the user had selected from the list, or if they pushed Enter after typing in the file name text field. This is important for when the JFileChooser does not have the associated Open/Save buttons associated with it that seem to trigger reading and storing the text field contents into SelectedFile. If user types into the text field without pressing return or the Open/Save button, it is impossible to retrieve that string. For an example, see NetBeans (using v 3.3, but probably exists in earlier and later versions), File | Mount Filesystem wizard, "Select Directory" panel. Request a way to retrieve the contents of the text field - whether it be to have getSelectedFile() return this, or some other method. Name: rmT116609 Date: 12/12/2002 DESCRIPTION OF THE PROBLEM : If the user types a file name after having selected a file, the file returned by getSelectedFile is null. STEPS TO FOLLOW TO REPRODUCE THE PROBLEM : 1.Compile and run the program below 2. Select a file 3. Change its name in the "File name" text box 4. Press Open. EXPECTED VERSUS ACTUAL BEHAVIOR : expected: the file name typed should be printed actual: null is printed REPRODUCIBILITY : This bug can be reproduced always. ---------- BEGIN SOURCE ---------- import javax.swing.*; public class Teste { public static void main(String[] args) { JFileChooser fc = new JFileChooser(); fc.setMultiSelectionEnabled(true); if (fc.showDialog(null, null) != JFileChooser.APPROVE_OPTION) return; System.out.println(fc.getSelectedFile()); } } ---------- END SOURCE ---------- (Review ID: 165557) ======================================================================
|