107054600
003008529
000000070
004905100
800700900
012003000
700000006
200609004
036010000
The files store a Sudoku puzzle in this way.
I have to be able to read these puzzles into both a 2d int array and a 2d Jlabel array.
It works when reading into the Int array alone. However, when I try assign the icon value of the j Label with the current number being processed by the for loop I get this compiler error:
The constructor javax.swing.JLabel(int) is undefined
Why is this?
The relevant code is below:
JLabel[][] gridLabels = new JLabel[9][9];
int [][] grid = new int [9][9]; // Game Array
try {
String fileName1 = new Scanner(new File("./temp.txt")).useDelimiter("\\Z").next();
Scanner fin;
fin = new Scanner( new File(fileName1));
//Reads in the puzzle from a temporary text file
for(int row=0; row<9; row++)
{
String line = fin.next();
for(int col=0; col<9; col++)
{ grid[row][col] = line.charAt(col)-'0';
gridLabels[row][col] = new JLabel(line.charAt(col)-'0'); //PROBLEM HERE//
}
}
}
catch (FileNotFoundException exception)
{System.out.println("Incorrect Selection"); // Catches incorrect selection
}
catch (NoSuchElementException exception)
{System.out.println("No Such Element");
}