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

JFileChooser.getSelectedFile() returns null if file does not exist in disk

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Duplicate
    • Icon: P3 P3
    • None
    • 1.3.0
    • client-libs
    • generic, x86
    • generic, windows_nt

      Name: skT88420 Date: 10/25/99
      1 Show a JFileChooser() dialog for opening or saving a file.
      If you select a file in the listbox, but type in the textfield
      a different name that does not exist,
            JFileChooser.getSelectedFile() will return null

      2
        public static String getFileW(JComponent parent) {
          if (wChooser == null) wChooser = new JFileChooser();
          int returnVal = wChooser.showSaveDialog(parent);
          if (returnVal == JFileChooser.APPROVE_OPTION) {
            File file = wChooser.getSelectedFile();

      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)

      java -fullversion
      java full version "1.3beta-O"
      (Review ID: 96963)
      ======================================================================

      Name: mc57594 Date: 01/10/2000


      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)

      1. Use JFileChooser to open a Save File dialog by calling
      showSaveDialog(Frame);

      2. When the dialog is displayed, the user first chooses an existing file from
      the list. This causes the file name to be copied into the text area at the
      bottom of the dialog, where it can now be edited. The user now edits the file
      name so that it represents a file that isn't on the disk.

      3. Dismiss the dialog. The function getSelectedFile() now returns null.

      If the user simply types the entire filename without first choosing an existing
      file from the list, the problem doesn't occur; getSelectedFile() will return the
      proper file name.
      (Review ID: 99800)
      ======================================================================

            jeff Jeff Dinkins
            skonchad Sandeep Konchady
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: