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

Nimbus L&F: Can't get icon with UIManager.getIcon("FileView.directoryIcon");

XMLWordPrintable

      FULL PRODUCT VERSION :
      java version "1.6.0_05-ea"
      Java(TM) SE Runtime Environment (build 1.6.0_05-ea-b04)
      Java HotSpot(TM) Client VM (build 1.6.0_05-ea-b04, mixed mode, sharing)

      ADDITIONAL OS VERSION INFORMATION :
      Microsoft Windows XP [Version 5.1.2600]

      A DESCRIPTION OF THE PROBLEM :
      Most other look and feels allow the developer to get the icon used to represent a directory or folder by using the code:

      Icon folderIcon = UIManager.getIcon("FileView.directoryIcon");

      This works on Metal, and the system look and feels on Windows, Mac, and Linux.

      It does not work with Nimbus.

      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      Set the look and feel to Nimbus and render a button with the icon value set to that returned from:
       UIManager.getIcon("FileView.directoryIcon")

      e.g.
      JButton browseButton = new JButton(UIManager.getIcon("FileView.directoryIcon"));


      EXPECTED VERSUS ACTUAL BEHAVIOR :
      EXPECTED -
      The icon used for folders should be returned.
      ACTUAL -
      return value of null

      REPRODUCIBILITY :
      This bug can be reproduced always.

      ---------- BEGIN SOURCE ----------
      package nimbusbug;

      import javax.swing.JButton;
      import javax.swing.JFrame;
      import javax.swing.JLabel;
      import javax.swing.JPanel;
      import javax.swing.SwingUtilities;
      import javax.swing.UIManager;

      public class Main {

          public static void main(String[] args) {
      SwingUtilities.invokeLater(new Runnable() {
      public void run() {
      iconTest();
      }
      });
          }

      public static void iconTest() {
      boolean showBug = true; // change to see the results with System L&F
      try {
      UIManager.setLookAndFeel(
      showBug
      ? "sun.swing.plaf.nimbus.NimbusLookAndFeel"
      : UIManager.getSystemLookAndFeelClassName());
      } catch (Exception e) {
      e.printStackTrace();
      }
              JFrame frame = new JFrame("Nimbus Issues");
      JButton browseButton = new JButton(UIManager.getIcon("FileView.directoryIcon"));
      JPanel p = new JPanel();
      p.add(new JLabel("This would make a greate 'browse' button:"));
      p.add(browseButton);
      frame.setContentPane(p);
      frame.pack();
      frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
      frame.setVisible(true);
      }
      }

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

            jasper Jasper Potts (Inactive)
            ryeung Roger Yeung (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: