kerorokun 发表于 2011-10-15 15:49

s1万能系列。。。。JAVA GUI设计。。。

jComboBox1.setModel(new DefaultComboBoxModel(player.getBackPack().toArray()));

player class:

    public Player(Position position, String name, double maxStamina,
                  double maxBackpackWeight, double maxBackpackSize)
    {
       this.position          = position;
       this.name            = name;
       this.maxStamina      = maxStamina;
       this.stamina = maxStamina;
       this.maxBackpackWeight = maxBackpackWeight;
       this.maxBackpackSize = maxBackpackSize;
       this.alive = true;
       this.backpack = new HashSet<Item>();
    }

    public Set<Item> getBackPack()
    {
      return this.backpack;
    }

Exception in thread "main" java.lang.NullPointerException
      at nz.ac.aut.prog2.ass3.gui.LemurIslandUI.initComponents(LemurIslandUI.java:249)
      at nz.ac.aut.prog2.ass3.gui.LemurIslandUI.<init>(LemurIslandUI.java:33)
      at nz.ac.aut.prog2.ass3.Main.main(Main.java:24)
求解。。。。。现在错误就指着jComboBox1.setModel这里。。。。完全没有头绪啊

gsm0251321 发表于 2011-10-15 16:24

NullPointerException
空指针你妹啊.....
检查下player以及player.getBackPack()是否为NULL

kerorokun 发表于 2011-10-15 16:36

恩。。。指定了GAME内的PLAYER后通过。。。。继续写下去。。。。
页: [1]
查看完整版本: s1万能系列。。。。JAVA GUI设计。。。