3个回答
展开全部
import java.awt.EventQueue;
import java.awt.Image;
import java.io.File;
import javax.imageio.ImageIO;
import javax.swing.JFrame;
public class IconFrame extends JFrame {
public IconFrame init(){
this.setDefaultCloseOperation(EXIT_ON_CLOSE);
this.setSize(300,200);
try {
Image image = ImageIO.read(new File("INPUT YOUR IMAGE FILE NAME HERE!"));
this.setIconImage(image);
} catch (Exception e) {
e.printStackTrace();
}
return this;
}
public static void main(String[] args){
EventQueue.invokeLater(new Runnable(){
public void run(){
new IconFrame().init().setVisible(true);
}
});
}
}
import java.awt.Image;
import java.io.File;
import javax.imageio.ImageIO;
import javax.swing.JFrame;
public class IconFrame extends JFrame {
public IconFrame init(){
this.setDefaultCloseOperation(EXIT_ON_CLOSE);
this.setSize(300,200);
try {
Image image = ImageIO.read(new File("INPUT YOUR IMAGE FILE NAME HERE!"));
this.setIconImage(image);
} catch (Exception e) {
e.printStackTrace();
}
return this;
}
public static void main(String[] args){
EventQueue.invokeLater(new Runnable(){
public void run(){
new IconFrame().init().setVisible(true);
}
});
}
}
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询