JFileChooser and "Details View"

When using JFileChooser, the Detailed View button appears. Each file displays 5 units of information. Icon, name, size, type and "Date modified". Which class controls the Type value? Using the FileView class, you can control the icon and name. Using the File class, you can control the size and the Modified Date. The description of the types is very good, and I would like to use them in other places, I also have some "new" types that I would like to be able to give a Description of "Type".

+3
source share
3 answers
import javax.swing.*;
import javax.swing.filechooser.*;
import java.io.*;


public class A {
public static void main(String[] args) {
    File f = new File("f.jpg");
    JFileChooser j = new JFileChooser();
    System.out.println(j.getTypeDescription(f));
}
}

:

F: > javac A.java

F: > java A

JPG IrfanView

, IrfanView ; JFileChooser/FileView β†’ getTypeDescription() ( Windows) . , (, camickr) getTypeDescription() ( Windows HKEY_CLASSES_ROOT).

0

, , Java, JFileChooser FileSystemView.

  • FileSystemView MyFileSystemView

  • override getSystemTypeDescription ( f)

  • in this redefinition for your special file type, return everything you need and return the default value by returning the value with a super call otherwise

  • create an instance of FileChoosers with one of the following prototypes, providing your own MyFileSystemView as the second argument

JFileChooser (File currentDirectory, FileSystemView fsv)

JFileChooser (String currentDirectoryPath, FileSystemView fsv)

0
source

All Articles