在我制作的这个应用程序中,用户点击一个按钮,该按钮启动一个程序。这个按钮将具有应用程序的标题和图标。我只需要知道如何获取图标,类似于这样:Windows http://goo.gl/5WjdT
因此,我想知道以下内容:
- Java中是否有任何真正的方法来实现这一点?
- 如果有,你会怎么做?
提前感谢!
在我制作的这个应用程序中,用户点击一个按钮,该按钮启动一个程序。这个按钮将具有应用程序的标题和图标。我只需要知道如何获取图标,类似于这样:Windows http://goo.gl/5WjdT
因此,我想知道以下内容:
提前感谢!
public static void main(String[] args) {
Icon icon = FileSystemView.getFileSystemView()
.getSystemIcon(new File("C:\\Windows\\regedit.exe"));
JFrame frame = new JFrame();
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.add(new JLabel(icon));
frame.pack();
frame.setVisible(true);
}
String s = "c:/windows/regedit.exe";
File file = new File(s);
// Get metadata and create an icon
sun.awt.shell.ShellFolder sf =
sun.awt.shell.ShellFolder.getShellFolder(file);
Icon icon = new ImageIcon(sf.getIcon(true));
Icon icon = FileSystemView.getFileSystemView().getSystemIcon(f);
- TiyebM