Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Java - Keep getting NullPointerExemption
#5
SaptaZapta Wrote:You need to allocate memory for SkillLabels before you can access its cells.

my bad. I looked up more information on arrays, and I beleive I was able to allocate memory correctly, but im still getting the same error. did I do it wrong?

Code:
int skill = 1;
JLabel[][] SkillLabels;
SkillLabels = new JLabel[10][10];
while (skill < 4) {
    SkillLabels[skill][1] = new JLabel(SkillDatabase.Skills[1].getName());
    SkillLabels[skill][2] = new JLabel("Current Level:");
    SkillLabels[skill][3] = new JLabel("Current Stats:");
    SkillLabels[skill][4] = new JLabel(SkillDatabase.Skills[1].getDesc());
    LevelSkill[skill] = new JButton("Level Skill");
    LevelSkill[skill].addActionListener(this);
    skill++;
        }
Reply


Messages In This Thread
Java - Keep getting NullPointerExemption - by Yugidude - 2013-02-24, 09:24 PM

Forum Jump:


Users browsing this thread: 1 Guest(s)