I have a JavaFX application which permits the user to select a file. The file could be an application.
I want to display the file's icon in an JavaFX ImageView
.
Is there a cross-platform solution to get such icon image and display it in an ImageView
?
You can get the default system icon for a file by using FileSystemView
:
ImageIcon icon = (ImageIcon) FileSystemView.getFileSystemView().getSystemIcon(file);
java.awt.Image image = icon.getImage();
You can later use SwingFXUtils to convert it to FX Image and set it to an ImageView.
Also go through JavaFX file listview with icon and file name .
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.