我想更改项目的图标而不是java图标。当状态栏显示程序图标时,应该显示自定义图标,而不是默认的java图标。
我正在使用以下代码。请建议我这段代码有什么问题。
class newframe extends JFrame
{
Container cp;
newframe()
{
cp=this.getContentPane();
cp.setLayout(null);
}
public static void main(String args[])
{
newframe frm= new newframe();
frm.setbounds(0,0,1000,800);
frm.setVisible(true);
ImageIcon im1= new ImageIcon("path upto image");
frm.setIconImage(im1.getImage());
}
}
最佳答案
..new ImageIcon("path upto image");
框架图标通常是嵌入式资源,因此必须通过 URL
访问,而不是通过 File<(表示路径的
.String
)访问
关于java - 在 JFrame 中设置图标,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12892166/