public class fileiconextractor extends jframe implements actionlistener{
private jbutton geticonbtn = new jbutton("get icon");
private jpanel iconpanel = new jpanel();
private jtextfield extfield = new jtextfield();
private jlabel smalliconlabel = new jlabel("small icon here");
private jlabel bigiconlabel = new jlabel("big icon here");
public fileiconextractor() {
this.setsize(200, 150);
this.setdefaultcloseoperation(jframe.exit_on_close);
this.setlayout(new borderlayout());
geticonbtn.setactioncommand("geticon");
geticonbtn.addactionlistener(this);
iconpanel.setlayout(new boxlayout(iconpanel, boxlayout.y_axis));
iconpanel.add(smalliconlabel);
iconpanel.add(bigiconlabel);
this.add(extfield, borderlayout.north);
this.add(iconpanel, borderlayout.center);
this.add(geticonbtn, borderlayout.south);
this.setvisible(true);
}
public void actionperformed(actionevent e) {
if (e.getactioncommand().equals("geticon")) {
string ext = extfield.gettext();
file file;
try
{
file = file.createtempfile("icon", "." + ext);
filesystemview view = filesystemview.getfilesystemview();
icon smallicon = view.getsystemicon(file);
shellfolder shellfolder = shellfolder.getshellfolder(file);
icon bigicon = new imageicon(shellfolder.geticon(true));
seticonlabel(smallicon, bigicon);
file.delete();
}
catch (ioexception ioe)
{
ioe.printstacktrace();
}
}
}
private void seticonlabel(icon smallicon, icon bigicon) {
smalliconlabel.seticon(smallicon);
bigiconlabel.seticon(bigicon);
}
public static void main(string[] args) {
fileiconextractor fie = new fileiconextractor();
}
}
如对本文有疑问, 点击进行留言回复!!
NullPointerException: Attempt to invoke virtual method ‘android.content.res.XmlResourceParser androi
关于启动appium-desktop,报错:Cannot extract apk info using apkanalyzer. Falling back to aapt. Original ....
Gradle 发布共享库——如何通过Gradle发布Android依赖库(aar)到 jitpack 公共仓库
Gradle 发布共享库——如何通过Gradle发布java依赖库(jar)到 jitpack 公共仓库(—)
网友评论