private void addItem(File directory){
  if (directory == null) {
    return;
  }
  boolean useShellFolder=FilePane.usesShellFolder(chooser);
  directories.clear();
  File[] baseFolders=(useShellFolder) ? (File[])ShellFolder.get("fileChooserComboBoxFolders") : fsv.getRoots();
  directories.addAll(Arrays.asList(baseFolders));
  File canonical;
  try {
    canonical=directory.getCanonicalFile();
  }
 catch (  IOException e) {
    canonical=directory;
  }
  try {
    File sf=useShellFolder ? ShellFolder.getShellFolder(canonical) : canonical;
    File f=sf;
    Vector<File> path=new Vector<File>(10);
    do {
      path.addElement(f);
    }
 while ((f=f.getParentFile()) != null);
    int pathCount=path.size();
    for (int i=0; i < pathCount; i++) {
      f=path.get(i);
      if (directories.contains(f)) {
        int topIndex=directories.indexOf(f);
        for (int j=i - 1; j >= 0; j--) {
          directories.insertElementAt(path.get(j),topIndex + i - j);
        }
        break;
      }
    }
    calculateDepths();
    setSelectedItem(sf);
  }
 catch (  FileNotFoundException ex) {
    calculateDepths();
  }
}

private void addItem ( File directory ) { if ( directory == null ) { return ; } boolean useShellFolder = FilePane . usesShellFolder ( chooser ) ; directories . clear ( ) ; File [ ] baseFolders = ( useShellFolder ) ? ( File [ ] ) ShellFolder . get ( "fileChooserComboBoxFolders" ) : fsv . getRoots ( ) ; directories . addAll ( Arrays . asList ( baseFolders ) ) ; File canonical ; try { canonical = directory . getCanonicalFile ( ) ; } catch ( IOException e ) { canonical = directory ; } try { File sf = useShellFolder ? ShellFolder . getShellFolder ( canonical ) : canonical ; File f = sf ; Vector < File > path = new Vector < File > ( 10 ) ; do { path . addElement ( f ) ; } while ( ( f = f . getParentFile ( ) ) != null ) ; int pathCount = path . size ( ) ; for ( int i = 0 ; i < pathCount ; i ++ ) { f = path . get ( i ) ; if ( directories . contains ( f ) ) { int topIndex = directories . indexOf ( f ) ; for ( int j = i - 1 ; j >= 0 ; j -- ) { directories . insertElementAt ( path . get ( j ) , topIndex + i - j ) ; } break ; } } calculateDepths ( ) ; setSelectedItem ( sf ) ; } catch ( FileNotFoundException ex ) { calculateDepths ( ) ; } }
adds the directory to the model and sets it to be selected , additionally clears out the previous selected directory and the paths leading up to it , if any .
