2013-02-24, 04:07 PM
So as im working on teaching myself java, but im stuck on a problem and i was hoping someone could show me what im missing.
1. Im trying to make a GUI, and what you see above are the various JLabels in it. The while loop (should) loop 3 times, once for each of the three skills my game has. The SkillDatabase.Skills stuff is where i keep the information on each skill (what it does, what its called, what its current level is, etc)
2. When i run this code, i get a NullPointerExemption, and it tells me the first line in the loop is the problem. I have tried re-aranging the loop, and it always errors on the 1st one.
3. In case the point of the loop isnt clear, I have a 2D Array of JLabels (the first brackets represents skill#, 2nd represents one of it's four JLabels), and i am trying to assign all of the Values to it in an easy way.
Well, thats it. I beleive i have attached all the code that caused the problem, but if something else is needed just lemme know.
Thanks!
Code:
JLabel[][] SkillLabels
int skill = 1;
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++;
}1. Im trying to make a GUI, and what you see above are the various JLabels in it. The while loop (should) loop 3 times, once for each of the three skills my game has. The SkillDatabase.Skills stuff is where i keep the information on each skill (what it does, what its called, what its current level is, etc)
2. When i run this code, i get a NullPointerExemption, and it tells me the first line in the loop is the problem. I have tried re-aranging the loop, and it always errors on the 1st one.
3. In case the point of the loop isnt clear, I have a 2D Array of JLabels (the first brackets represents skill#, 2nd represents one of it's four JLabels), and i am trying to assign all of the Values to it in an easy way.
Well, thats it. I beleive i have attached all the code that caused the problem, but if something else is needed just lemme know.
Thanks!

