1

I have made a program which shows my C and D drive. But the icons which are coming in my output are the default icons of javaFx. I just want to show all icons of my system. For example for videos it should show the media icon for my system, not the default icon in javaFx.

Tab Alleman
  • 31,483
  • 7
  • 36
  • 52
Samraat
  • 11
  • 7
  • 1
    Please add your code (and screenshot) because I am not really sure what actualy the question is. – DVarga Jul 01 '16 at 12:47

1 Answers1

2

This question is similar to:

That related question does not provide a native JavaFX solution.

However, there is currently no native JavaFX solution, so it would be best to:

  1. Use the Swing classes referenced in the similar question.
  2. Extract a BufferedImage from the icons, using:

  3. Use SwingFXUtils.toFXImage to convert the BufferedImage to a JavaFX Image.

The related question suggests (and I haven't tried it) to do:

Icon icon = FileSystemView.getFileSystemView().getSystemIcon(File);

Or (if OS X):

javax.swing.JFileChooser fc = new javax.swing.JFileChooser();
Icon icon = fc.getUI().getFileView(fc).getIcon(file);

After writing this answer, I found the following question which is similar (perhaps this is even a duplicate):

Community
  • 1
  • 1
jewelsea
  • 150,031
  • 14
  • 366
  • 406