[英]How to set an icon image for an application?
试试看。
frame.setIconImage(new ImageIO.read(new File("res/game.png")));
其中res / game.png是您要使用的图标图像
https://docs.oracle.com/javase/7/docs/api/javax/swing/ImageIcon.html#ImageIcon(java.lang.String)
https://docs.oracle.com/javase/tutorial/uiswing/components/frame.html
frame.setIconImage(new ImageIcon(getClass().getResource("logo.png")).getImage()
当图像与类位于同一程序包中时,此方法有效。 注意:最好将图像放在资源文件夹中
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.