📄 spatialfilefilter.java
字号:
package jwo.jpss.spatial.gui;
import javax.swing.filechooser.*;
import java.io.File;
// **************************************************************
/** Provides a file filter to allow only spatial files to be
* to be displayed in a JFileChooser.
* @author Jo Wood.
* @version 1.3, 11th October, 2001.
*/
// **************************************************************
public class SpatialFileFilter extends FileFilter
{
// ---------------------- Class variables -------------------
private static final String[] extensions = {"gis","grd","txt","xml"};
// ------------------- Implemented Methods ------------------
/** Filters only file extensions of known spatial file formats.
* @param file File to consider displaying.
* @return true if file has a recognised spatial filename extension.
*/
public boolean accept(File file)
{
if (file.isDirectory())
return true;
// Find file name extension.
String fileName = file.getName();
int i = fileName.lastIndexOf('.');
if ((i > 0) && (i < fileName.length()-1))
{
String ext = fileName.substring(i+1);
for (int extNum=0; extNum<extensions.length; extNum++)
{
if (ext.equalsIgnoreCase(extensions[extNum]))
return true;
}
}
return false;
}
/** Reports the description of this filter for the file chooser.
* @return Description of this filter.
*/
public String getDescription()
{
return new String("Spatial files");
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -