Jeu Java ne fonctionne pas


J'ai trouvé ce code source java pour un jeu de casse-briques en ligne. Je l'ai téléchargé et j'ai essayé de l'exécuter mais cela me donne une NullPointerException. Qu'est-ce qui donne cette exception et comment la réparer? Grâce.

Http://zetcode.com/tutorials/javagamestutorial/breakout/

Voici le stacktrace:

Exception in thread "main" java.lang.NullPointerException
    at javax.swing.ImageIcon.<init>(ImageIcon.java:181)
    at Ball.<init>(Ball.java:16)
    at Board.gameInit(Board.java:48)
    at Board.addNotify(Board.java:43)
    at java.awt.Container.addNotify(Container.java:2578)
    at javax.swing.JComponent.addNotify(JComponent.java:4685)
    at java.awt.Container.addNotify(Container.java:2578)
    at javax.swing.JComponent.addNotify(JComponent.java:4685)
    at java.awt.Container.addNotify(Container.java:2578)
    at javax.swing.JComponent.addNotify(JComponent.java:4685)
    at javax.swing.JRootPane.addNotify(JRootPane.java:739)
    at java.awt.Container.addNotify(Container.java:2578)
    at java.awt.Window.addNotify(Window.java:663)
    at java.awt.Frame.addNotify(Frame.java:470)
    at java.awt.Window.show(Window.java:859)
    at java.awt.Component.show(Component.java:1584)
    at java.awt.Component.setVisible(Component.java:1536)
    at java.awt.Window.setVisible(Window.java:842)
    at Breakout.<init>(Breakout.java:14)
    at Breakout.main(Breakout.java:18)
Exception in thread "Timer-0" java.lang.NullPointerException
    at Board$ScheduleTask.run(Board.java:110)
    at java.util.TimerThread.mainLoop(Timer.java:512)
    at java.util.TimerThread.run(Timer.java:462)

Apparemment, ce code est censé fonctionner, mais ce n'est pas le cas.

Author: dudewhat14, 2012-04-16

1 answers

Vous n'avez probablement pas également téléchargé les images, ou du moins ne les avez pas placées dans le bon dossier. Assurez-vous de mettre les images ici:

Parcourir à la balle.java, montez deux niveaux de dossier, créez-y un dossier appelé images et mettez-y vos images.

 5
Author: Martijn Courteaux, 2012-04-16 19:05:44