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

JFileChooser Does trim() Only for Single Selection Mode

XMLWordPrintable



      Name: jk109818 Date: 10/01/2002


      FULL PRODUCT VERSION :
      java version "1.4.1"
      Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.1-b21)
      Java HotSpot(TM) Client VM (build 1.4.1-b21, mixed mode)


      FULL OPERATING SYSTEM VERSION :
      SunOS fletchu5 5.8 Generic_108528-16 sun4u sparc SUNW,Ultra-
      5_10

      ADDITIONAL OPERATING SYSTEMS :
      Also happens in Windows 2000.



      A DESCRIPTION OF THE PROBLEM :
      The JFileChooser will trim() whitespace from a filename
      when in single selection mode. It will not do the trim()
      when multiple selection is enabled.

      Search for trim() in
      javax.swing.plaf.basic.BasicFileChooserUI.java to see the
      bug in the code.

      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      1. Run FileChooserDemo supplied with the 1.4.1 FCS SDK
      demo programs.
      2. Make sure "Single Selection" is selected
      3. Select a filename that contains a space as its first
      character. For example " image.tif". The space will get
      trimmed when the filename is selected.
      4. Now choose "Multi Selection".
      5. Make sure you select the filename that contains the
      space as its first character, along with some other files.
      The space will not get trimmed from the filename.

      EXPECTED VERSUS ACTUAL BEHAVIOR :
      In both cases I expected to get the filename I selected
      without having the whitespace trimmed.

      What really happened is the whitespace got trimmed in
      single selection mode and didn't get trimmed in multiple
      selection mode.

      When the whitespace gets trimmed in single selection mode
      our program is unable to open the selected file since the
      filename is incorrect.

      ERROR MESSAGES/STACK TRACES THAT OCCUR :
      No error messages.

      REPRODUCIBILITY :
      This bug can be reproduced always.

      ---------- BEGIN SOURCE ----------
      see source code in 1.4.1 FCS installation directory
      demo/jfc/FileChooserDemo/src.
      ---------- END SOURCE ----------

      CUSTOMER WORKAROUND :
      None that I know of.

      The trim() is in
      javax.swing.plaf.basic.BasicFileChooserUI.java. I could
      probably comment out the trim() in BasicFileChooserUI.java
      but I'm not real fond of this kind of fix.
      (Review ID: 165126)
      ======================================================================

            loneid Leonid Popov (Inactive)
            jkimsunw Jeffrey Kim (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: