本文整理汇总了Java中javax.swing.filechooser.FileSystemView.getSystemIcon方法的典型用法代码示例。如果您正苦于以下问题:Java FileSystemView.getSystemIcon方法的具体用法?Java FileSystemView.getSystemIcon怎么用?Java FileSystemView.getSystemIcon使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javax.swing.filechooser.FileSystemView
的用法示例。
在下文中一共展示了FileSystemView.getSystemIcon方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: createImageIconView
import javax.swing.filechooser.FileSystemView; //导入方法依赖的package包/类
/**
* 파일로부터 이미지를 그리기 위한 뷰를 반환한다.
*
* @Date 2015. 10. 14.
* @param file
* @return
* @User KYJ
*/
public static ImageView createImageIconView(File file) {
Image fxImage = null;
if (file.exists()) {
FileSystemView fileSystemView = FileSystemView.getFileSystemView();
Icon icon = fileSystemView.getSystemIcon(file);
BufferedImage bufferedImage = new BufferedImage(icon.getIconWidth(), icon.getIconHeight(), BufferedImage.TYPE_INT_ARGB);
icon.paintIcon(null, bufferedImage.getGraphics(), 0, 0);
fxImage = SwingFXUtils.toFXImage(bufferedImage, null);
} else {
return new ImageView();
}
return new ImageView(fxImage);
}
示例2: getIcon
import javax.swing.filechooser.FileSystemView; //导入方法依赖的package包/类
/** Return the icon of a File.
* <p>Unfortunately Windows and Mac require different
* approaches.
*
* @param file the file to get the icon of.
* @return an icon for this file.
*/
public static Icon getIcon(File file) {
if(file==null) throw new NullPointerException();
if(JVM.isWindows) {
//on Macs this appears to only return the vanilla folder/file icons:
FileSystemView fsv = FileSystemView.getFileSystemView();
Icon icon = fsv.getSystemIcon(file);
return icon;
} else {
//but this returns different icons for different folders/icons:
FileView fileView = getFileView();
return fileView.getIcon(file);
}
}
示例3: getIcon
import javax.swing.filechooser.FileSystemView; //导入方法依赖的package包/类
private Icon getIcon(File file) {
FileSystemView fileSystemView = FileSystemView.getFileSystemView();
Icon icon = fileSystemView.getSystemIcon(file);
return icon;
}