title: Java JFilechooser customization
body: <p>further to my question <a href="https://stackoverflow.com/questions/6859225/java-jfilechooser">Java JFilechooser</a>. It was suggested to extend  BasicFileChooserUI, overriding create/getModel and providing an implementation of BasicDirectoryModel.</p>
  
  <p>I attempted this however, I could not achieve it.</p>
  
  <p>JFileChooser does not have a setUI method. So your only choice is to override getUI.</p>
  
  <pre><code>    JFileChooser blah = new JFileChooser()
      {
          CustomFileChooserUI asdf = null;
          /**
           * 
           */
          private static final long serialVersionUID = 1L;
  
          public FileChooserUI getUI() 
          {
              if (asdf == null)
              {
                  asdf = new CustomFileChooserUI(this);
              }
              return asdf;
          }
      };
  </code></pre>
  
  <p>and </p>
  
  <pre><code>public class CustomFileChooserUI extends BasicFileChooserUI
  {
      public CustomFileChooserUI(JFileChooser b) 
      {
          super(b);
      }
  
      @Override
      protected void createModel() 
      {
          // TODO Auto-generated method stub
          super.createModel();
      }
  }
  </code></pre>
  
  <p>but i get exceptions. Please help</p>
  
  <blockquote>
    <p>java.lang.reflect.InvocationTargetException
        at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
        at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
        at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
        at java.lang.reflect.Constructor.newInstance(Unknown Source)
        at org.eclipse.ve.internal.java.vce.launcher.remotevm.JavaBeansLauncher.main(JavaBeansLauncher.java:86)
    Caused by: java.lang.NullPointerException
        at javax.swing.plaf.basic.BasicFileChooserUI$BasicFileView.getName(Unknown Source)IWAV0052E Invocation Target Exception creating qwere</p>
  </blockquote>
  
  <pre><code>at javax.swing.JFileChooser.getName(Unknown Source)
  at javax.swing.plaf.metal.MetalFileChooserUI$DirectoryComboBoxRenderer.getListCellRendererComponent(Unknown Source)
  at javax.swing.plaf.basic.BasicListUI.updateLayoutState(Unknown Source)
  at javax.swing.plaf.basic.BasicListUI.maybeUpdateLayoutState(Unknown Source)
  at javax.swing.plaf.basic.BasicListUI$Handler.valueChanged(Unknown Source)
  at javax.swing.DefaultListSelectionModel.fireValueChanged(Unknown Source)
  at javax.swing.DefaultListSelectionModel.fireValueChanged(Unknown Source)
  at javax.swing.DefaultListSelectionModel.fireValueChanged(Unknown Source)
  at javax.swing.DefaultListSelectionModel.changeSelection(Unknown Source)
  at javax.swing.DefaultListSelectionModel.changeSelection(Unknown Source)
  at javax.swing.DefaultListSelectionModel.setSelectionInterval(Unknown Source)
  at javax.swing.JList.setSelectedIndex(Unknown Source)
  at javax.swing.plaf.basic.BasicComboPopup.setListSelection(Unknown Source)
  at javax.swing.plaf.basic.BasicComboPopup.access$300(Unknown Source)
  at javax.swing.plaf.basic.BasicComboPopup$Handler.itemStateChanged(Unknown Source)
  at javax.swing.JComboBox.fireItemStateChanged(Unknown Source)
  at javax.swing.JComboBox.selectedItemChanged(Unknown Source)
  at javax.swing.JComboBox.contentsChanged(Unknown Source)
  at javax.swing.AbstractListModel.fireContentsChanged(Unknown Source)
  at javax.swing.plaf.metal.MetalFileChooserUI$DirectoryComboBoxModel.setSelectedItem(Unknown Source)
  at javax.swing.plaf.metal.MetalFileChooserUI$DirectoryComboBoxModel.addItem(Unknown Source)
  at javax.swing.plaf.metal.MetalFileChooserUI$DirectoryComboBoxModel.access$900(Unknown Source)
  at javax.swing.plaf.metal.MetalFileChooserUI.doDirectoryChanged(Unknown Source)
  at javax.swing.plaf.metal.MetalFileChooserUI.access$1200(Unknown Source)
  at javax.swing.plaf.metal.MetalFileChooserUI$5.propertyChange(Unknown Source)
  at java.beans.PropertyChangeSupport.firePropertyChange(Unknown Source)
  at java.beans.PropertyChangeSupport.firePropertyChange(Unknown Source)
  at java.awt.Component.firePropertyChange(Unknown Source)
  at javax.swing.JFileChooser.setCurrentDirectory(Unknown Source)
  at javax.swing.JFileChooser.&lt;init&gt;(Unknown Source)
  at javax.swing.JFileChooser.&lt;init&gt;(Unknown Source)
  at qwere$1.&lt;init&gt;(qwere.java:12)
  </code></pre>