-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathFileIconView.java
More file actions
31 lines (27 loc) · 833 Bytes
/
FileIconView.java
File metadata and controls
31 lines (27 loc) · 833 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
package fileChooser;
import javax.swing.*;
import javax.swing.filechooser.FileFilter;
import javax.swing.filechooser.FileView;
import java.io.File;
/**
* A file view that displays an icon for all files that match a file filter.
*/
public class FileIconView extends FileView {
private FileFilter filter;
private Icon icon;
/**
* Constructs a FileIconView.
*
* @param filter a file filter--all files that this filter accepts
* will be shown with the icon.
* @param icon the icon shown with all accepted files.
*/
public FileIconView(FileFilter filter, Icon icon) {
this.filter = filter;
this.icon = icon;
}
public Icon getIcon(File file) {
if (!file.isDirectory() && filter.accept(file)) return icon;
else return null;
}
}