Javaでアイコン画像を設定する方法をどこでも検索してきましたが、常に機能しないか、エラーが発生します。ここで、私の主な方法は、コードを配置する場所です。
public static void main(String[] args) {
Game game = new Game();
// This right here!
game.frame.setIconImage(new ImageIcon("/Icon.png").getImage());
game.frame.setResizable(false);
game.frame.setTitle(title);
game.frame.add(game);
game.frame.pack();
game.frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
game.frame.setLocationRelativeTo(null);
game.frame.setVisible(true);
}
画像のパスは「%PROJECT%/res/Image.png」で、/Image.png を使用して res フォルダーにアクセスします (プロジェクトの他の部分で行ったように)。をアイコンファイルに変換して試してみましたが、デフォルトの Java アイコンを使用することしか決定されませんでした。