baharcglr
baharcglr

Reputation: 111

Setting a file's icon in java

//Getting a file's icon
File file = new File("t2.png");
FileSystemView view = FileSystemView.getFileSystemView();       
Icon icon = view.getSystemIcon(file);

Getting a file's icon can be done as above code in java.

What about setting a file's icon? How can it be done?

Upvotes: 3

Views: 299

Answers (1)

xikkub
xikkub

Reputation: 1660

Executables (.exe files on Windows) are the only files I know of which have individually "customizable" icons. All other files are given the same icon according to their file extension. For example, html files may have the Internet Explorer or Mozilla Firefox logo depending on the application that opens them by default. pdf files usually have the Adobe logo. As 'ulmangt' indicated, you can specify your own icons for files with specific file extensions by configuring the program used to open them by default. Good luck!

Upvotes: 1

Related Questions