一.报错译文
Deprecated constructor已弃用的构造函数URL.<init>(String)
is invoked
二.解决办法
官方说明文档:URL (Java SE21 & JDK 21),建议使用URI.toURL()
三.代码示例
//java 20弃用 new URL的所有构造函数
//报错代码
//ImageIcon imageIcon = new ImageIcon((new URL("https://codechrono.cn/wechatMiniKeyPng.png")), "wechatMiniPng");
//第一次尝试
//ImageIcon imageIcon = new ImageIcon(new URL("https","codechrono.cn",80,"/wechatMiniKeyPng.png"), "wechatMiniPng");
//第二次尝试,成功代码 URI.toURL()
ImageIcon imageIcon = new ImageIcon(((new URI("https://codechrono.cn/wechatMiniKeyPng.png")).toURL()), "wechatMiniPng");