获取的重点在于FileSystemView.getFileSystemView().getSystemIcon(file)这个方法
直接运行下面例子可以看到效果..请注意
File file=new File("d:\\xx.exe");
 
import java.awt.Image;
import java.io.File;
import javax.swing.ImageIcon;
import javax.swing.JFrame;
import javax.swing.filechooser.FileSystemView;
public class Iccon {
JFrame jFrame;
/**
* @param args
*/

public static void main(String[] args) {
new Iccon().statrt();
}
void statrt()
{
jFrame=new JFrame();
jFrame.setBounds(200, 200, 200, 200);
File file=new File("d:\\xx.exe");
jFrame.setIconImage(((ImageIcon) FileSystemView.getFileSystemView().getSystemIcon(file)).getImage());
jFrame.setVisible(true);
}
}

 



相关文章:

  • 2022-12-23
  • 2021-05-03
  • 2021-11-22
  • 2021-09-06
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2021-07-30
  • 2021-10-21
  • 2022-12-23
  • 2021-08-13
  • 2021-06-14
  • 2022-01-10
相关资源
相似解决方案