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

Unable to instantiate JFileChooser with a minimal BasicL&F descendant installed

    Details

    • Subcomponent:
    • Resolved In Build:
      b116
    • CPU:
      generic
    • OS:
      generic
    • Verification:
      Verified

      Description

      Platform: all
      JDK: 6, 7

      The following code sets minimal Basic L&F descendant and then tries to instantiate JFileChooser.
      As the result NPE is thrown and some info is printed to System.err
      -------------------------------------------------------------------
      import javax.swing.*;
      import javax.swing.plaf.basic.*;

      public class FileChooserTest {

          public static void main(String[] args) throws Exception {
              SwingUtilities.invokeAndWait(new Runnable() {
                  public void run() {
                      try {
                          UIManager.setLookAndFeel(new BasicLookAndFeel() {
                              @Override public String getName() { return "A name"; }
                              @Override public String getID() { return "An id"; }
                              @Override public String getDescription() { return "A description"; }
                              @Override public boolean isNativeLookAndFeel() { return false; }
                              @Override public boolean isSupportedLookAndFeel() { return true; }
                          });
                      } catch (UnsupportedLookAndFeelException e) {
                          e.printStackTrace();
                      }
                      new JFileChooser();
                  }
              });
          }
      }

      -------------------------------------------------------------------
      For JDK7b103 output is the following

      java.lang.NullPointerException
      at javax.swing.JFileChooser.updateUI(JFileChooser.java:1794)
      at javax.swing.JFileChooser.setup(JFileChooser.java:374)
      at javax.swing.JFileChooser.<init>(JFileChooser.java:347)
      at javax.swing.JFileChooser.<init>(JFileChooser.java:300)
      at FileChooserTest$1.run(FileChooserTest.java:20)

      UIDefaults.getUI() failed: no ComponentUI class for: javax.swing.JFileChooser[,0,0,0x0,invalid,alignmentX=0.0,alignmentY=0.0,border=,flags=0,maximumSize=,minimumSize=,preferredSize=,approveButtonText=,currentDirectory=,dialogTitle=,dialogType=OPEN_DIALOG,fileSelectionMode=FILES_ONLY,returnValue=ERROR_OPTION,selectedFile=,useFileHiding=true]
      java.lang.Error
      at javax.swing.UIDefaults.getUIError(UIDefaults.java:728)
      at javax.swing.MultiUIDefaults.getUIError(MultiUIDefaults.java:130)
      at javax.swing.UIDefaults.getUI(UIDefaults.java:758)
      at javax.swing.UIManager.getUI(UIManager.java:1002)
      at javax.swing.JFileChooser.updateUI(JFileChooser.java:1787)
      at javax.swing.JFileChooser.setup(JFileChooser.java:374)
      at javax.swing.JFileChooser.<init>(JFileChooser.java:347)
      at javax.swing.JFileChooser.<init>(JFileChooser.java:300)
      at FileChooserTest$1.run(FileChooserTest.java:20)

      JCK tests fail because of this problem

        Attachments

          Activity

            People

            • Assignee:
              rupashka Pavel Porvatov (Inactive)
              Reporter:
              dbessono Dmitry Bessonov
            • Votes:
              0 Vote for this issue
              Watchers:
              0 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:
                Imported:
                Indexed: