/* * [PNGFileFilter.java] * * Summary: Creates a file filter that accepts only *.png files. * * Copyright: (c) 2004-2017 Roedy Green, Canadian Mind Products, http://mindprod.com * * Licence: This software may be copied and used freely for any purpose but military. * http://mindprod.com/contact/nonmil.html * * Requires: JDK 1.8+ * * Created with: JetBrains IntelliJ IDEA IDE http://www.jetbrains.com/idea/ * * Version History: * 1.8 2009-04-04 Mask, command line version of Masker. */ package com.mindprod.masker; import javax.swing.filechooser.FileFilter; import java.io.File; /** * Creates a file filter that accepts only *.png files. * * @author Roedy Green, Canadian Mind Products * @version 1.8 2009-04-04 Mask, command line version of Masker. * @since 2004-05-19 */ final class PNGFileFilter extends FileFilter { /** * Creates a file filter that accepts only *.png files. */ public PNGFileFilter() { } /** * Return true if this file should be shown in the directory pane, false if it shouldn't. accepts directories and * .PNG files. * * @param f file/directory to test * * @return true if this * @see java.io.FileFilter#accept(File) */ public boolean accept( File f ) { if ( f != null ) { if ( f.isDirectory() ) { return true; } String name = f.getName().toLowerCase(); return name.endsWith( ".png" ); } else { return false; } } /** * Returns the human readable description of this filter. * * @return description of what this filter produces */ public String getDescription() { return "*.png image files"; } }