Night | Snow

get default system icon in java

Posted on: September 20th, 2009

Tags: , ,

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):

String ext = ".pdf";
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

News

Martin Fischer said:

Client and partner of simra.ch

Wir können Simon Schärer als kompetenter und zuverlässiger Programmierer höchst weiterempfehlen. Er ist nicht nur ein guter Programmierer, sondern auch ein ausgezeichneter Designer.
Danke Developer’s Island

Follow us on Twitter

favorite

I get asked a lot - which SDK should we use for web programming? I recommend Netbeans

my toolbar

Simra GameMP3 playersubscribe to RSSMy delicious bookmarksFacebookTwitterE-mail

No Responses to “get default system icon in java”

RSS Feed Icon  Subscribe to comments follow-up

Trackbacks/Pingbacks

Leave a reply

You can use these tags:
<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

Latest Tweet

loading...