Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8314930

Invalid file name is approved from JFileChooser TextField.

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Unresolved
    • Icon: P3 P3
    • tbd
    • 8, 11, 17, 21
    • client-libs
    • None
    • Fix Understood
    • generic
    • generic

      ADDITIONAL SYSTEM INFORMATION :
      Operating System Details
      System Windows 10.

      Java SE Version
      Version "20.0.1"

      A DESCRIPTION OF THE PROBLEM :
      Detailed Description of the Problem
      1) Type any invalid file/folder name in File Name Text Field provided.
      2) Click Approve button.
      3) Even though the file does not exists in respective folder, the name entered is accepted and set as selected file.

      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      Steps to Reproduce
      Run the application in source code

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      Expected Result
      Error message when invalid file is entered through Text Field (As in other native applications like notepad)
      ACTUAL -
      Actual Result
      Invalid name is accepted and set as selected file.

      ---------- BEGIN SOURCE ----------
      import javax.swing.JFrame;
      import javax.swing.JFileChooser;
      import java.io.File;

      public class TestFileChooser {
          public static void main(String[] args) {
              JFileChooser fChooser = new JFileChooser();

              fChooser.setDialogTitle("Please select folder...");
              fChooser.setFileSelectionMode(JFileChooser.FILES_AND_DIRECTORIES );

              int returnVal = fChooser.showOpenDialog(new JFrame());

              if (returnVal == JFileChooser.APPROVE_OPTION) {
                  File file = fChooser.getSelectedFile();
                  System.out.println("selected: " + file.getAbsolutePath());
              }
          }
      }


      ---------- END SOURCE ----------

      FREQUENCY : always

            tr Tejesh R
            tr Tejesh R
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated: