imagefileview.java
来自「初期JAVA学习非常有用的资料。帮助深入了解API。特别是Applet。」· Java 代码 · 共 58 行
JAVA
58 行
import java.io.File;import javax.swing.*;import javax.swing.filechooser.*;public class ImageFileView extends FileView { ImageIcon jpgIcon = new ImageIcon("images/jpgIcon.gif"); ImageIcon gifIcon = new ImageIcon("images/gifIcon.gif"); ImageIcon tiffIcon = new ImageIcon("images/tiffIcon.gif"); public String getName(File f) { return null; // let the L&F FileView figure this out } public String getDescription(File f) { return null; // let the L&F FileView figure this out } public Boolean isTraversable(File f) { return null; // let the L&F FileView figure this out } public String getTypeDescription(File f) { String extension = Utils.getExtension(f); String type = null; if (extension != null) { if (extension.equals(Utils.jpeg) || extension.equals(Utils.jpg)) { type = "JPEG Image"; } else if (extension.equals(Utils.gif)){ type = "GIF Image"; } else if (extension.equals(Utils.tiff) || extension.equals(Utils.tif)) { type = "TIFF Image"; } } return type; } public Icon getIcon(File f) { String extension = Utils.getExtension(f); Icon icon = null; if (extension != null) { if (extension.equals(Utils.jpeg) || extension.equals(Utils.jpg)) { icon = jpgIcon; } else if (extension.equals(Utils.gif)) { icon = gifIcon; } else if (extension.equals(Utils.tiff) || extension.equals(Utils.tif)) { icon = tiffIcon; } } return icon; }}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?