get default system icon in java
Posted on: September 20th, 2009
Tags: createTempFile, FileSystemView, JFileChooser
You can use the JFileChooser class to get the small system type icons (16×16). To get the icon, you just need to specify a file on the file system for which you want to get the icon. Here is a little example (works on mac os and windows):
File file = File.createTempFile("icon", ext);
String osName = System.getProperty("os.name").toLowerCase();
boolean isMacOs = osName.startsWith("mac os x");
if (isMacOs) {
JFileChooser chooser = new JFileChooser();
icon = chooser.getIcon(file);
} else {
icon = FileSystemView.getFileSystemView().getSystemIcon(file);
}
Posted in Java | Trackback Url








No Responses to “get default system icon in java”
Trackbacks/Pingbacks
Leave a reply