I am working on an game assignment for my class in eclipse. I have been getting an error:
ClassNotFoundException(throwable);
It stops in
public static Jewel[][] grid = new Jewel[8][8];
While running the debugger it doesnt seem to enter the new Jewel[8][8]
i certanly have the Jewel Class in the same package, and i cant figure out why it cant find the class. I am assuming that it is trying to generate a different class or the static portion of the class is not being generated at compile time. Any additional comments are welcome;
here is the whole class this is located in
package game;
import java.awt.Dimension;
import java.awt.Graphics;
import java.awt.Graphics2D;
import javax.swing.JPanel;
public class PlayArea extends JPanel {
private static final long serialVersionUID = -9165676032115582474L;
public static Jewel[][] grid = new Jewel[8][8];
public PlayArea(){
this.setPreferredSize(new Dimension(Common.jewelWidth*Common.rowColLength,Common.jewelWidth*Common.rowColLength));
this.setLayout(null);
for(int i = 0; i < Common.rowColLength; i++){
for (int j = 0; j < Common.rowColLength; j++){
grid[i][j] = new Jewel();
}
}
}
@Override
public void paintComponent(Graphics g){
Graphics2D g2 = (Graphics2D) g;
for (int i = 0; i <Common.rowColLength;i++){
for(int j = 0; j < Common.rowColLength; j++){
grid[i][j].drawJewel(i, j, g2);
}
}
Jewel grid2 = new Jewel();
grid2.drawJewel(1, 1, g2);
}
}
This will not create instances of Jewel class but merely references to it. You have to explicitly iterate over your 2D array and create new Jewel instances.
This is where it will go inside the constructor if you have some code in your default constructor.