请问Mac OS X上怎么取得系统文件(例如,Desktop)的图标图像?Icon icon = FileSystemView.getFileSystemView().getSystemIcon(getFile());
这里得到的 icon 是个apple.laf.CUIAquaIcon 类对象,没有 getImage() 方法。

解决方案 »

  1.   

    Try this: Icon icon = FileSystemView.getFileSystemView().getSystemIcon(getFile());
    int width = icon.getIconWidth();
    int height  = icon.getIconHeight();
    BufferedImage img = new BufferedImage(width,height,BufferedImage.TYPE_INT_RGB);
    Graphics g = img.getGraphics();
    g.setColor(Color.white);
    g.fillRect(0, 0, width, height);
    icon.paintIcon(null, g, 0, 0);
    try {
    ImageIO.write(img, "jpg", new File("c:/1.jpg"));
    } catch (IOException e) {
    // Make it silent here.
    }
      

  2.   

    Oh, BufferedImage is an Image actually. Maybe you needn't to get it exported to a image file.I haven't got OS 10 on hand, but the interface is all the same on any platform.Have fun.