A kérdésem a következő: Java nyelvben grafikus felületnél, van egy snakes programom ami tökéletesen lefut semmi hibát nem kap, de mégsem jeleníti meg magát a játékot grafikusan. Mi lehet a probléma?
Exception in thread "AWT-EventQueue-1" java.lang.NullPointerException
at snake.snakeCanvas.DrawFruit(snakeCanvas.java:239)
at snake.snakeCanvas.paint(snakeCanvas.java:77)
at sun.awt.RepaintArea.paintComponent(RepaintArea.java:264)
at sun.awt.RepaintArea.paint(RepaintArea.java:240)
at sun.awt.windows.WComponentPeer.handleEvent(WComponentPeer.java:348)
at java.awt.Component.dispatchEventImpl(Component.java:4954)
at java.awt.Component.dispatchEvent(Component.java:4700)
at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:743)
at java.awt.EventQueue.access$400(EventQueue.java:97)
at java.awt.EventQueue$3.run(EventQueue.java:694)
at java.awt.EventQueue$3.run(EventQueue.java:691)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:75)
at java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:86)
at java.awt.EventQueue$4.run(EventQueue.java:716)
at java.awt.EventQueue$4.run(EventQueue.java:714)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:75)
at java.awt.EventQueue.dispatchEvent(EventQueue.java:713)
at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:220)
at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:135)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:123)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:119)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:111)
at java.awt.EventDispatchThread.run(EventDispatchThread.java:97)
Exception in thread "AWT-EventQueue-1" java.lang.NullPointerException
at snake.snakeCanvas.DrawFruit(snakeCanvas.java:239)
at snake.snakeCanvas.paint(snakeCanvas.java:77)
at sun.awt.RepaintArea.paintComponent(RepaintArea.java:264)
at sun.awt.RepaintArea.paint(RepaintArea.java:240)
at sun.awt.windows.WComponentPeer.handleEvent(WComponentPeer.java:348)
at java.awt.Component.dispatchEventImpl(Component.java:4954)
at java.awt.Component.dispatchEvent(Component.java:4700)
at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:743)
at java.awt.EventQueue.access$400(EventQueue.java:97)
at java.awt.EventQueue$3.run(EventQueue.java:694)
at java.awt.EventQueue$3.run(EventQueue.java:691)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:75)
at java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:86)
at java.awt.EventQueue$4.run(EventQueue.java:716)
at java.awt.EventQueue$4.run(EventQueue.java:714)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:75)
at java.awt.EventQueue.dispatchEvent(EventQueue.java:713)
at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:220)
at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:135)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:123)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:119)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:111)
at java.awt.EventDispatchThread.run(EventDispatchThread.java:97)
Exception in thread "AWT-EventQueue-1" java.lang.NullPointerException
at snake.snakeCanvas.DrawFruit(snakeCanvas.java:239)
at snake.snakeCanvas.paint(snakeCanvas.java:77)
at snake.snakeCanvas.update(snakeCanvas.java:112)
at sun.awt.RepaintArea.updateComponent(RepaintArea.java:255)
at sun.awt.RepaintArea.paint(RepaintArea.java:232)
at sun.awt.windows.WComponentPeer.handleEvent(WComponentPeer.java:348)
at java.awt.Component.dispatchEventImpl(Component.java:4954)
at java.awt.Component.dispatchEvent(Component.java:4700)
at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:743)
at java.awt.EventQueue.access$400(EventQueue.java:97)
at java.awt.EventQueue$3.run(EventQueue.java:694)
at java.awt.EventQueue$3.run(EventQueue.java:691)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:75)
at java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:86)
at java.awt.EventQueue$4.run(EventQueue.java:716)
at java.awt.EventQueue$4.run(EventQueue.java:714)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:75)
at java.awt.EventQueue.dispatchEvent(EventQueue.java:713)
at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:220)
at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:135)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:123)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:119)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:111)
at java.awt.EventDispatchThread.run(EventDispatchThread.java:97)
Exception in thread "AWT-EventQueue-1" java.lang.NullPointerException
at snake.snakeCanvas.DrawFruit(snakeCanvas.java:239)
at snake.snakeCanvas.paint(snakeCanvas.java:77)
at snake.snakeCanvas.update(snakeCanvas.java:112)
at sun.awt.RepaintArea.updateComponent(RepaintArea.java:255)
at sun.awt.RepaintArea.paint(RepaintArea.java:232)
at sun.awt.windows.WComponentPeer.handleEvent(WComponentPeer.java:348)
at java.awt.Component.dispatchEventImpl(Component.java:4954)
at java.awt.Component.dispatchEvent(Component.java:4700)
at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:743)
at java.awt.EventQueue.access$400(EventQueue.java:97)
at java.awt.EventQueue$3.run(EventQueue.java:694)
at java.awt.EventQueue$3.run(EventQueue.java:691)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:75)
at java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:86)
at java.awt.EventQueue$4.run(EventQueue.java:716)
at java.awt.EventQueue$4.run(EventQueue.java:714)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:75)
at java.awt.EventQueue.dispatchEvent(EventQueue.java:713)
at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:220)
at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:135)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:123)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:119)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:111)
at java.awt.EventDispatchThread.run(EventDispatchThread.java:97)
Exception in thread "AWT-EventQueue-1" java.lang.NullPointerException
at snake.snakeCanvas.DrawFruit(snakeCanvas.java:239)
at snake.snakeCanvas.paint(snakeCanvas.java:77)
at snake.snakeCanvas.update(snakeCanvas.java:112)
at sun.awt.RepaintArea.updateComponent(RepaintArea.java:255)
at sun.awt.RepaintArea.paint(RepaintArea.java:232)
at sun.awt.windows.WComponentPeer.handleEvent(WComponentPeer.java:348)
at java.awt.Component.dispatchEventImpl(Component.java:4954)
at java.awt.Component.dispatchEvent(Component.java:4700)
at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:743)
at java.awt.EventQueue.access$400(EventQueue.java:97)
at java.awt.EventQueue$3.run(EventQueue.java:694)
at java.awt.EventQueue$3.run(EventQueue.java:691)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:75)
at java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:86)
at java.awt.EventQueue$4.run(EventQueue.java:716)
at java.awt.EventQueue$4.run(EventQueue.java:714)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:75)
at java.awt.EventQueue.dispatchEvent(EventQueue.java:713)
at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:220)
at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:135)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:123)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:119)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:111)
at java.awt.EventDispatchThread.run(EventDispatchThread.java:97)
Exception in thread "AWT-EventQueue-1" java.lang.NullPointerException
at snake.snakeCanvas.DrawFruit(snakeCanvas.java:239)
at snake.snakeCanvas.paint(snakeCanvas.java:77)
at snake.snakeCanvas.update(snakeCanvas.java:112)
at sun.awt.RepaintArea.updateComponent(RepaintArea.java:255)
at sun.awt.RepaintArea.paint(RepaintArea.java:232)
at sun.awt.windows.WComponentPeer.handleEvent(WComponentPeer.java:348)
at java.awt.Component.dispatchEventImpl(Component.java:4954)
at java.awt.Component.dispatchEvent(Component.java:4700)
at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:743)
at java.awt.EventQueue.access$400(EventQueue.java:97)
at java.awt.EventQueue$3.run(EventQueue.java:694)
at java.awt.EventQueue$3.run(EventQueue.java:691)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:75)
at java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:86)
at java.awt.EventQueue$4.run(EventQueue.java:716)
at java.awt.EventQueue$4.run(EventQueue.java:714)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:75)
at java.awt.EventQueue.dispatchEvent(EventQueue.java:713)
at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:220)
at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:135)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:123)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:119)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:111)
at java.awt.EventDispatchThread.run(EventDispatchThread.java:97)
Exception in thread "AWT-EventQueue-1" java.lang.NullPointerException
at snake.snakeCanvas.DrawFruit(snakeCanvas.java:239)
at snake.snakeCanvas.paint(snakeCanvas.java:77)
at snake.snakeCanvas.update(snakeCanvas.java:112)
at sun.awt.RepaintArea.updateComponent(RepaintArea.java:255)
at sun.awt.RepaintArea.paint(RepaintArea.java:232)
at sun.awt.windows.WComponentPeer.handleEvent(WComponentPeer.java:348)
at java.awt.Component.dispatchEventImpl(Component.java:4954)
at java.awt.Component.dispatchEvent(Component.java:4700)
at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:743)
at java.awt.EventQueue.access$400(EventQueue.java:97)
at java.awt.EventQueue$3.run(EventQueue.java:694)
at java.awt.EventQueue$3.run(EventQueue.java:691)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:75)
at java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:86)
at java.awt.EventQueue$4.run(EventQueue.java:716)
at java.awt.EventQueue$4.run(EventQueue.java:714)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:75)
at java.awt.EventQueue.dispatchEvent(EventQueue.java:713)
at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:220)
at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:135)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:123)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:119)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:111)
at java.awt.EventDispatchThread.run(EventDispatchThread.java:97)
Exception in thread "AWT-EventQueue-1" java.lang.NullPointerException
at snake.snakeCanvas.DrawFruit(snakeCanvas.java:239)
at snake.snakeCanvas.paint(snakeCanvas.java:77)
at snake.snakeCanvas.update(snakeCanvas.java:112)
at sun.awt.RepaintArea.updateComponent(RepaintArea.java:255)
at sun.awt.RepaintArea.paint(RepaintArea.java:232)
at sun.awt.windows.WComponentPeer.handleEvent(WComponentPeer.java:348)
at java.awt.Component.dispatchEventImpl(Component.java:4954)
at java.awt.Component.dispatchEvent(Component.java:4700)
at java.awt.EventQueue.dispatchEventImpl(EventQueue.java:743)
at java.awt.EventQueue.access$400(EventQueue.java:97)
at java.awt.EventQueue$3.run(EventQueue.java:694)
at java.awt.EventQueue$3.run(EventQueue.java:691)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:75)
at java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:86)
at java.awt.EventQueue$4.run(EventQueue.java:716)
at java.awt.EventQueue$4.run(EventQueue.java:714)
at java.security.AccessController.doPrivileged(Native Method)
at java.security.ProtectionDomain$1.doIntersectionPrivilege(ProtectionDomain.java:75)
at java.awt.EventQueue.dispatchEvent(EventQueue.java:713)
at java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:220)
at java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:135)
at java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:123)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:119)
at java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:111)
at java.awt.EventDispatchThread.run(EventDispatchThread.java:97)
Bocsanat, azok a hibak voltak amiket ki ir mind, de ezt nem ertem mert irja Exception in thread "Thread-3" Exception in thread "AWT-EventQueue-1" java.lang.NullPointerException
Ja es hogy lehet egy kepet be ''importalni'' mert nekem olyan opcio nincsen>?????
Képet beolvasni egy fájlból a javax.imageio.ImageIO.read(File) metódussal tudsz.
A NullPointerException azt jelenti, hogy egy null értékű változón próbáltál elérni egy metódust, változót, ....
Ez a snakeCanvas osztály 239. sorában történt meg. Ha a kódot bemásolod segítünk.
Jó tanács:
Az osztályneveket nagy, a metódusokét kis betűvel kezd.
Ne csinálj óriási osztályokat, bontsd részekre (a 239 sor soknak tűnik). Így egyszerűbb a hibakeresés, könnyebb módosítani, és "biztonságosabb".
Kapcsolódó kérdések:
Minden jog fenntartva © 2024, www.gyakorikerdesek.hu
GYIK | Szabályzat | Jogi nyilatkozat | Adatvédelem | Cookie beállítások | WebMinute Kft. | Facebook | Kapcsolat: info(kukac)gyakorikerdesek.hu
Ha kifogással szeretne élni valamely tartalommal kapcsolatban, kérjük jelezze e-mailes elérhetőségünkön!