本文整理匯總了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;
}