具有基于java的作战系统和nimbus GUI的XML解析故事系统中的空指针异常

时间:2016-09-03 07:53:48

标签: java xml swing jdom nimbus

我目前有两个视频游戏;一个故事板系统,从XML文件中读取一个场景,然后显示场景的描述和玩家与之交互的选项列表,以及一个以类似的方式工作的战斗系统,只有玩家提示直接来自java系统而不是XML。我把这两件事放在一起很麻烦。我已经结合了两者的代码但是,在结合两个工作程序时,我最终得到了两个NullPointerExceptions来自DefaultListModel,在每个实例中至少有一个值。我无法弄清楚为什么它仍被抛出为NULL。

我无法在此输入我的代码,因为它超过了30000个字符,所以这里是指向版本控制存储库的链接:

https://github.com/jpinaz92/Itc303-textAdventure/commit/59a24a677b85ec237d9270c75592e09fd43cb9e6

如果某人能够找出导致所有这些问题的原因,它会帮助我,如果有办法在这里发布我的代码,即使它超过30000个字符让我知道,我会这样做。

以下是完整输出:

java.lang.NullPointerException
    at textadventure.TextAdventureGUI2.initComponents(TextAdventureGUI2.java:199)
    at textadventure.TextAdventureGUI2.<init>(TextAdventureGUI2.java:150)
    at textadventure.TextAdventureGUI2$1.run(TextAdventureGUI2.java:107)
    at java.awt.event.InvocationEvent.dispatch(Unknown Source)
    at java.awt.EventQueue.dispatchEventImpl(Unknown Source)
    at java.awt.EventQueue.access$500(Unknown Source)
    at java.awt.EventQueue$3.run(Unknown Source)
    at java.awt.EventQueue$3.run(Unknown Source)
    at java.security.AccessController.doPrivileged(Native Method)
    at java.security.ProtectionDomain$1.doIntersectionPrivilege(Unknown Source)
    at java.awt.EventQueue.dispatchEvent(Unknown Source)
    at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)
    at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
    at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
    at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
    at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
    at java.awt.EventDispatchThread.run(Unknown Source)
Exception in thread "main" java.lang.NullPointerException
    at textadventure.TextAdventureGUI2.initComponents(TextAdventureGUI2.java:199)
    at textadventure.TextAdventureGUI2.<init>(TextAdventureGUI2.java:150)
    at textadventure.TextAdventureGUI2.main(TextAdventureGUI2.java:146)

1 个答案:

答案 0 :(得分:0)

我修复了它的问题是在初始化列表模型需要的参数。