"C:\Program Files\Java\jdk-15.0.1\bin\java.exe" "-javaagent:D:\intelej idea\int idea setup\IntelliJ IDEA Community Edition 2020.3.2\lib\idea_rt.jar=54827:D:\intelej idea\int idea setup\IntelliJ IDEA Community Edition 2020.3.2\bin" -Dfile.encoding=UTF-8 -classpath "D:\intelej idea\java_int_idea\game_catch_hte_dropp\out\production\game_catch_hte_dropp" com.company.Game_window
Exception in thread "main" java.lang.IllegalArgumentException: input == null!
at java.desktop/javax.imageio.ImageIO.read(ImageIO.java:1356)
at com.company.Game_window.main(Game_window.java:18)
Process finished with exit code 1
И сам код
package com.company;
import javax.imageio.ImageIO;
import javax.swing.*;
import java.awt.*;
import java.io.IOException;
public class Game_window extends JFrame {
private static Game_window game_window;
public static Image rain;
public static Image dropp;
public static Image game_over;
public static void main(String[] args) throws IOException
{
rain = ImageIO.read(Game_window.class.getResourceAsStream("rain.jpg"));
dropp = ImageIO.read(Game_window.class.getResourceAsStream("dropp.jpg"));
game_over = ImageIO.read(Game_window.class.getResourceAsStream("game_over"));
game_window = new Game_window();
game_window.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);
game_window.setLocation(200,100);
game_window.setSize(906,478);
game_window.setResizable(false);
GameField game_field = new GameField();
game_window.add(game_field);
game_window.setVisible(true);
}
private static void onRepaint(Graphics g)
{
g.drawImage(rain, 0, 0, null);
g.drawImage(dropp, 100,100, null);
g.drawImage(game_over, 280,120, null);
}
private static class GameField extends JPanel
{
@Override
protected void paintComponent(Graphics g)
{
super.paintComponent(g);
onRepaint(g);
}
}
}