selectedIndex = -1; FileFilter selected = (FileFilter) e.getNewValue(); for (int i = 0; i < filters.length; i++) if (filters[i].equals(selected)) selectedIndex = i;
JFileChooser fc = getFileChooser(); FileFilter[] choosableFilters = fc.getChoosableFileFilters(); filters = choosableFilters; fireContentsChanged(this, 0, filters.length); selected = e.getNewValue();
    public void propertyChange(PropertyChangeEvent e)    {      if (e.getPropertyName().equals(JFileChooser.FILE_FILTER_CHANGED_PROPERTY))        {          selectedIndex = -1;          FileFilter selected = (FileFilter) e.getNewValue();          for (int i = 0; i < filters.length; i++)            if (filters[i].equals(selected))              selectedIndex = i;          fireContentsChanged(this, -1, -1);        }      else if (e.getPropertyName().equals(              JFileChooser.CHOOSABLE_FILE_FILTER_CHANGED_PROPERTY))        {          // repopulate list          JFileChooser fc = getFileChooser();          FileFilter[] choosableFilters = fc.getChoosableFileFilters();          filters = choosableFilters;          fireContentsChanged(this, 0, filters.length);        }    }