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

  • Apple lays App Store rules bare

    Apple says that it will publish the guidelines it uses to determine which programs it sells in its App Store to appease critical developers.

  • Google unveils 'instant' searches

    Google speeds up its internet search engine by launching a new product called Instant that displays results as soon as users type in queries.

  • Smartphone chip battle heats up

    Intel is to launch its first chip with built-in graphics, while established phone chipmaker ARM releases a fast new chip.

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...