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

exception throws when call getSystemIcon for root drives with removable media

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: P3 P3
    • 1.4.0
    • 1.4.0
    • client-libs
    • beta2
    • x86
    • windows_2000


      ingrid.yao@Eng 2001-05-22

      J2SE Version (please include all output from java -version flag):


      C:\>java -version
      java version "1.4.0-beta"
      Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.0-beta-b64)
      Java HotSpot(TM) Client VM (build 1.4.0-beta-b64, mixed mode)
      C:\>

      Does this problem occur on J2SE 1.3? Yes / No (pick one)
          Not a feature of JDK1.3


      Operating System Configuration Information (be specific):
         Windows 2000 Professional.


      Hardware Configuration Information (be specific):
         Toshiba Tecra 8100 (Laptop) 733 MHZ system with 512M memory.


      Bug Description:
       
      Throws exception when try to get the System Icon for root drives with
      removable media.

         The drive names (roots) are retrieved properly. But it throws the
      exception if the removable media does not exists. ex: if the CD Media
      does not exists in the CD or DVD Drive, it will throw the exception.
      Same with Floppy drive if the floppy does not exists, it will throw exception.

         If the floppy is in the floppy drive or CD is in the CD/DVD drive
      the icons are shown properly.

         Here is the exception sample:

         Total root : 5
         Root : A: FileSystemView.getShellFolder: f=A: java.io.FileNotFoundException
      at sun.awt.shell.ShellFolder.getShellFolder(ShellFolder.java:192)
      at javax.swing.filechooser.FileSystemView.getShellFolder(FileSystemView.java:447)
      at javax.swing.filechooser.FileSystemView.getSystemIcon(FileSystemView.java:182)
         at testjdk14.TestJFC.testForRoots(TestJFC.java:93)
      at testjdk14.TestJFC.main(TestJFC.java:115)

         Root : C: Got icon.
         Root : D: Got icon.
         Root : E: FileSystemView.getShellFolder: f=E: java.io.FileNotFoundException
      at sun.awt.shell.ShellFolder.getShellFolder(ShellFolder.java:192)
      at javax.swing.filechooser.FileSystemView.getShellFolder(FileSystemView.java:447)

      at javax.swing.filechooser.FileSystemView.getSystemIcon(FileSystemView.java:182)
      at testjdk14.TestJFC.testForRoots(TestJFC.java:93)
      at testjdk14.TestJFC.main(TestJFC.java:115)
         Root : F: Got icon.

      Test Case
      --------------
      /**
       * Title: TestJFC1.java
       * Description: Test the JDK 1.4 JFC Stuff.
       * Copyright: Copyright (c) 2001
       * Company:
       * @author Harimohan S. Bawa
       * @version 1.0
       */

      import java.io.*;
      import java.awt.*;
      import javax.swing.*;
      import javax.swing.filechooser.*;

      public class TestJFC1 {

            public TestJFC1() {
                  try {
                        UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName());
                  }
                  catch(Exception e) {
                        e.printStackTrace();
                  }
            }


            public void testForRoots(){
                   try{

      // Return only one root file : Desktop - Incorrect
                      //File [] files_get = FileSystemView.getFileSystemView().getRoots();
      // Returns all root files properly. - Correct
                      File [] files_list = File.listRoots();
                      System.out.println("Total root from listRoots: " + files_list.length);

                        for (int i = 0; i < files_list.length; i++){
                            System.out.println("Root(listRoots) : " + files_list[i]);
                            // Try to get Icon
                            try{
                                  Icon icon = FileSystemView.getFileSystemView().getSystemIcon(files_list[i]);
                                  if (icon == null){
                                     System.out.println("Icon is null.");
                                  } else {
                                     System.out.println("Got icon.");
                                  }
                            }catch (Exception e){
                            }
                        }
                   }catch (Exception e){
                          System.err.println("Exception caught : ");
                          e.printStackTrace();
                   }
            }




            public static void main(String[] args) {
                  TestJFC1 test = new TestJFC1();
      test.testForRoots();
                  System.exit(0);
            }
      }

            leifs Leif Samuelsson (Inactive)
            tyao Ting-Yun Ingrid Yao (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: