< prev index next >

## src/java.desktop/share/classes/com/sun/java/swing/plaf/motif/MotifFileChooserUI.java

Print this page

    rev 48358 : Work in progress for JDK-6303622
    Use generic in Swing components like JComboBox
    1. Added generic return type and parameter type for JComboBox.
    2. Modified JList related classes as well.

     800      */
     801     @SuppressWarnings("serial") // Superclass is not serializable across versions
     802     protected class FilterComboBoxModel extends AbstractListModel<FileFilter> implements ComboBoxModel<FileFilter>,
     803             PropertyChangeListener {
     804         protected FileFilter[] filters;
     805         protected FilterComboBoxModel() {
     806             super();
     807             filters = getFileChooser().getChoosableFileFilters();
     808         }
     809
     810         public void propertyChange(PropertyChangeEvent e) {
     811             String prop = e.getPropertyName();
     812             if(prop.equals(JFileChooser.CHOOSABLE_FILE_FILTER_CHANGED_PROPERTY)) {
     813                 filters = (FileFilter[]) e.getNewValue();
     814                 fireContentsChanged(this, -1, -1);
     815             } else if (prop.equals(JFileChooser.FILE_FILTER_CHANGED_PROPERTY)) {
     816                 fireContentsChanged(this, -1, -1);
     817             }
     818         }
     819
     820         public void setSelectedItem(Object filter) {
     821             if(filter != null) {
     822                 getFileChooser().setFileFilter((FileFilter) filter);
     823                 fireContentsChanged(this, -1, -1);
     824             }
     825         }
     826
     827         public Object getSelectedItem() {
     828             // Ensure that the current filter is in the list.
     829             // NOTE: we shouldnt' have to do this, since JFileChooser adds
     830             // the filter to the choosable filters list when the filter
     831             // is set. Lets be paranoid just in case someone overrides
     832             // setFileFilter in JFileChooser.
     833             FileFilter currentFilter = getFileChooser().getFileFilter();
     834             boolean found = false;
     835             if(currentFilter != null) {
     836                 for (FileFilter filter : filters) {
     837                     if (filter == currentFilter) {
     838                         found = true;
     839                     }
     840                 }
     841                 if (!found) {
     842                     getFileChooser().addChoosableFileFilter(currentFilter);
     843                 }
     844             }
     845             return getFileChooser().getFileFilter();
     846         }
     847
     800      */
     801     @SuppressWarnings("serial") // Superclass is not serializable across versions
     802     protected class FilterComboBoxModel extends AbstractListModel<FileFilter> implements ComboBoxModel<FileFilter>,
     803             PropertyChangeListener {
     804         protected FileFilter[] filters;
     805         protected FilterComboBoxModel() {
     806             super();
     807             filters = getFileChooser().getChoosableFileFilters();
     808         }
     809
     810         public void propertyChange(PropertyChangeEvent e) {
     811             String prop = e.getPropertyName();
     812             if(prop.equals(JFileChooser.CHOOSABLE_FILE_FILTER_CHANGED_PROPERTY)) {
     813                 filters = (FileFilter[]) e.getNewValue();
     814                 fireContentsChanged(this, -1, -1);
     815             } else if (prop.equals(JFileChooser.FILE_FILTER_CHANGED_PROPERTY)) {
     816                 fireContentsChanged(this, -1, -1);
     817             }
     818         }
     819
     820         public void setSelectedItem(FileFilter filter) {
     821             if(filter != null) {
     822                 getFileChooser().setFileFilter(filter);
     823                 fireContentsChanged(this, -1, -1);
     824             }
     825         }
     826
     827         public FileFilter getSelectedItem() {
     828             // Ensure that the current filter is in the list.
     829             // NOTE: we shouldnt' have to do this, since JFileChooser adds
     830             // the filter to the choosable filters list when the filter
     831             // is set. Lets be paranoid just in case someone overrides
     832             // setFileFilter in JFileChooser.
     833             FileFilter currentFilter = getFileChooser().getFileFilter();
     834             boolean found = false;
     835             if(currentFilter != null) {
     836                 for (FileFilter filter : filters) {
     837                     if (filter == currentFilter) {
     838                         found = true;
     839                     }
     840                 }
     841                 if (!found) {
     842                     getFileChooser().addChoosableFileFilter(currentFilter);
     843                 }
     844             }
     845             return getFileChooser().getFileFilter();
     846         }
     847

< prev index next >