A tool class for obtaining high-definition images, which is used to replace FileSystemView and ShellFolder before JKD17.
English | 中文
import system.jni.JavaFXUtils;
class Test{
public static void main(String[] args) {
//init the class
JavaFXUtils.init();
//get the icon
JavaFXUtils.getIconImageFX(new File("test.exe"));
JavaFXUtils.getIconImageBytes(new File("test.exe"));
}
}
public static Image getIcon(File file) throws IOException {
if (file == null) {
throw new FileNotFoundException("File is null");
}
try {
return /*API*/;
}catch (Exception e){
log.error("Failed to get icon", e);
}
return null;
}
try {
return toFXImage(FileSystemView.getFileSystemView().getSystemIcon(file));
}catch (Exception e){
log.error("Failed to get icon", e);
}
try {
return toFXImage(ShellFolder.getShellFolder(file).getIcon(true));
}catch (Exception e){
log.error("Failed to get icon", e);
}
try {
return JavaFXUtils.getIconImageFX(file,1200);
}catch (Exception e){
log.error("Failed to get icon", e);
}